Skip to content

Walking Graphs

Alexandre Rabérin edited this page May 12, 2020 · 1 revision

Walking Graphs

Iterate vertices

Use the Vertices property to get an enumerable collection of vertices:

foreach(var vertex in graph.Vertices)
{
    Console.WriteLine(vertex);
}

Iterate edges

Use the Edges property get an enumerable collection of edges:

foreach(var edge in graph.Edges)
{
    Console.WriteLine(edge);
}

Iterate out-edges (in-edges)

The OutEdges method returns an enumerable collection of out-edges:

foreach(var vertex in graph.Vertices)
{
    foreach(var edge in graph.OutEdges(vertex))
    {
        Console.WriteLine(edge);
    }
}

Similarly, InEdges returns an enumerable collection of in-edges.

Clone this wiki locally