arber wrote:
Thanks for for the advice on the edges I'll have a look further into the class libraries. :)
tcap479 wrote:
I'll have a look at the simplegraphadaptor class. Although if I could get the first approach working then that would be preferrable. This is due to displaying a friends list might not be appropriate in this situation, as using an edge list wouldn't should friends(vertices) that dont have any friends in common as they wouldnt be shown in an edge list.
Below is a code example that I have used to graph Vertices.
I believe not being able to draw the edges is down to the way in which I have coded the above.
Could you guys give me a potential code/pseudo code example for looping through vertices and an edges, for a vertex list and an edge list?_
Really enjoying working with NodeXL, keep up the great work!
Thanks again Tony and Arber,
Matt
Hello Matt,Hey Arber,
when a vertex is created it gets a unique ID for the graph which can be accessed through the ID property of the vertex. The same applies to edges.
Regards,
Arber
Thanks for for the advice on the edges I'll have a look further into the class libraries. :)
tcap479 wrote:
Also, Matt, please note that there is a Smrf.NodeXL.Adapters.SimpleGraphAdapter class that will create a new graph for you by reading an edge list from a string, file, or stream, without your having to keep track of the vertices. You would use it something like this:Hey Tony,
SimpleGraphAdapter simpleGraphAdapter = new SimpleGraphAdapter();
IGraph newGraph = simpleGraphAdapter.LoadGraphFromFile("C:\MyTabDelimitedFile.txt");
nodeXLControl.Graph = newGraph;
I don't know if that would be useful in your particular situation, but I wanted to mention it.
-- Tony
I'll have a look at the simplegraphadaptor class. Although if I could get the first approach working then that would be preferrable. This is due to displaying a friends list might not be appropriate in this situation, as using an edge list wouldn't should friends(vertices) that dont have any friends in common as they wouldnt be shown in an edge list.
Below is a code example that I have used to graph Vertices.
protected void PopulateGraph(List<string> friends)
{// Get the graph's vertex collection.
IVertexCollection Ver = nodeXLControl1.Graph.Vertices;
IVertex[] test = new IVertex[friends.Count];
// Reads in data that has been grabbed from the Facebook API regarding User's friends.
// The data is then used to populate the graph.
for (int i = 0; i < friends.Count; i++)
{
//Adding a Vertex
test[i] = Ver.Add();
//Adding a tag for each vertext that the user can click on. (ccould display name, mutual friend count, etc..)
// test.Tag = ("This is Vertex: " + " " + i);
//Changed the characteristics of the Vertices created (eg. name, colour and shape)
test[i].SetValue(ReservedMetadataKeys.PerVertexLabel, (friends[i]));
test[i].SetValue(ReservedMetadataKeys.PerColor,
Color.FromArgb(0, 0, 0, 0));
test[i].SetValue(ReservedMetadataKeys.PerVertexLabelFillColor,
Color.FromArgb(255, 255, 255, 255));
test[i].SetValue(ReservedMetadataKeys.PerVertexShape,
VertexShape.Label);
}
_I believe not being able to draw the edges is down to the way in which I have coded the above.
Could you guys give me a potential code/pseudo code example for looping through vertices and an edges, for a vertex list and an edge list?_
Really enjoying working with NodeXL, keep up the great work!
Thanks again Tony and Arber,
Matt