-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFormGraphInfo.cs
53 lines (48 loc) · 1.78 KB
/
FormGraphInfo.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Graphiz
{
/// <summary>
/// Sole purpose of this form is to display computed information about the given graph.
/// A reference to the object is not stored.
/// The form is not updated if the graph is mutated after creation.
/// </summary>
public partial class FormGraphInfo : Form
{
public FormGraphInfo(Graph graph)
{
InitializeComponent();
this.textBoxOrder.Text = graph.Vertices.Count.ToString();
this.textBoxSize.Text = graph.Edges.Count.ToString();
this.textBoxDegreeSeq.Text =
graph.Vertices
.Select(vertex => graph.Edges
.Where(edge => edge.LeftID == vertex.Key || edge.RightID == vertex.Key).Count())
.OrderByDescending(i => i)
.Select(i => i.ToString())
.Intersperse(", ")
.Wrap("(", ")")
.AsString();
this.textBoxVertices.Text =
graph.Vertices
.Keys
.Select(i => i.ToString())
.Intersperse(", ")
.Wrap("{", "}")
.AsString();
this.richTextBoxEdges.Text =
graph.Edges
.Select(edge => string.Format("{{{0}, {1}}}", graph.Vertices[edge.LeftID].Name, graph.Vertices[edge.RightID].Name))
.Intersperse(", ")
.Wrap("{", "}")
.AsString();
}
}
}