1
Vote

Vertex selection from graph vertices

description

Hi,

Currently, i'm working on an XML File to create a graph from it.
Each vertex correspond to a question.
My aim is to create a question-answer path application in C#.

I wish to make edges between the parent vertex and a few vertexes which are already created but i don't know how to select a specific vertex (from the graph vertices) through the ID property. For each question, i had to create a new vertex (answer) and add an edge with the parent (question) to make it working but that's not what i want.

Looking for your expertise on GraphX.NET.
Advance thanks.

comments

arnoldar wrote Oct 13 at 11:13 AM

I solved the issue.

I add vertexes which correspond to my questions to my graph.
For each vertex in the graph, i retrieved the answers into a XMLNodeList.
For each answer, I just used Vertices.ToList() and then compare all my vertexes' text to my answer's text.

Here is the code below :

foreach (var v in dataGraph.Vertices.ToList())
                        {
                            //Si le successeur est dans la graph
                            if (v.Text == nQuestion.Attributes["text"].Value)
                            {
                                DataEdge edge = new DataEdge(question, v);
                                dataGraph.AddEdge(edge);
                            }
                        }