Jan 7, 2012 at 9:06 PM
Edited Jan 7, 2012 at 9:07 PM
Okay, now you're in the realm of what NodeXL can accomplish for you.
Here is an outline of an approach you might take:
1. Discard the NodeXL source code, or at least put it in a folder called NotRequiredAndIsDistracting.
2. Download the latest version of the NodeXL Class Libraries if you haven't already done so.
3. In Visual Studio 2008 or 2010, create a new solution with a new Windows Forms project.
4. In your Windows Forms project, add references to the following NodeXL assemblies:
5. In your Form1.cs file, import the following namespaces:
6. Create a Graph object and populate it with data-mined vertices. Note that a Graph object exists independently of its visual representation, so you can create and manipulate a Graph without ever showing it.
Graph oGraph = new Graph(GraphDirectedness.Undirected);
IVertexCollection oVertices = oGraph.Vertices;
IVertex oVertex1 = oVertices.Add();
IVertex oVertex2 = oVertices.Add();
IVertex oVertex3 = oVertices.Add();
7. Connect the vertices with edges:
IEdgeCollection oEdges = oGraph.Edges;
8. Lay out the graph within a 100x100 rectangle.. All the layout classes in NodeXL have one job, which is to set the Location property on each of the graph's vertices.
FruchtermanReingoldLayout oLayout = new FruchtermanReingoldLayout();
LayoutContext oLayoutContext = new LayoutContext(new Rectangle(0, 0, 100, 100));
9. Get the laid-out vertex locations.
Debug.WriteLine("oVertex1.Location = " + oVertex1.Location);
Debug.WriteLine("oVertex2.Location = " + oVertex2.Location);
Debug.WriteLine("oVertex3.Location = " + oVertex3.Location);
10. Calculate some graph metrics; vertex degree, for example. Note that there is an entire family of "GraphMetricCalculator" classes in the Smrf.NodeXL.Algorithms namespace.
VertexDegreeCalculator oVertexDegreeCalculator = new VertexDegreeCalculator();
Dictionary<Int32, VertexDegrees> oVertexDegreeDictionary = oVertexDegreeCalculator.CalculateGraphMetrics(oGraph);
Debug.WriteLine("Degree of oVertex1 = " + oVertexDegreeDictionary[oVertex1.ID].Degree);
Debug.WriteLine("Degree of oVertex2 = " + oVertexDegreeDictionary[oVertex2.ID].Degree);
Debug.WriteLine("Degree of oVertex3 = " + oVertexDegreeDictionary[oVertex3.ID].Degree);
11. See the NodeXLApi.chm help file for details about all these classes and more.