Fork us on GitHub

ImVader

ImVader is a flexible and powerful .NET framework for working with graphs. The project is hosted on Github and is absolutely free.

P.S. Project development is in alpha version, you should not use this framework in commercial projects yet.

Fork us on Github Full reference Download

Requirements


ImVader requires .NET 4.5 to be installed


Example usage

Initialiazing graph



//Initializing new list-base graph (vertices store integer values, edges are unweighted)
var m = new ListGraph<int, UnweightedEdge>();
//Adding vertices
int v0 = m.AddVertex(32);
int v1 = m.AddVertex(13);
int v2 = m.AddVertex(23);
int v3 = m.AddVertex(84);
int v4 = m.AddVertex(64);
//Adding edges
m.AddEdge(new UnweightedEdge(v0, v1));
m.AddEdge(new UnweightedEdge(v0, v4));
m.AddEdge(new UnweightedEdge(v0, v2));
m.AddEdge(new UnweightedEdge(v1, v2));
m.AddEdge(new UnweightedEdge(v1, v3));
m.AddEdge(new UnweightedEdge(v3, v4));

Managing graph



// Initializing new list-base weighted graph with 10 vertices and 1 edge with weight 23.5
var m = new ListGraph<int, WeightedEdge>(10);
int edge0 = m.AddEdge(new WeightedEdge(0, 1, 23.5));
// Setting the vertex with index 2 value 32
m.SetVertexData(2, 32);
// Removing vertex with index 2
m.RemoveVertex(2);
// Setting the edge with index edge0 weight 33
m.GetEdge(edge0).Weight = 33;
// Removing edge with index edge0
m.RemoveVertex(edge0);

Breadth-first search


            
var dirListGraph = new DirectedListGraph<int, edge>(5);
dirListGraph.AddEdge(new UnweightedEdge(0, 1));
dirListGraph.AddEdge(new UnweightedEdge(1, 3));
dirListGraph.AddEdge(new UnweightedEdge(0, 2));
dirListGraph.AddEdge(new UnweightedEdge(0, 3));
dirListGraph.AddEdge(new UnweightedEdge(3, 4));
var bfs = new BreadthFirstPathes<int, edge>(dirListGraph, 0);
var path = bfs.PathTo(4).ToArray();
foreach (var vertexId in path)
{
    Console.WriteLine(vertexId);
}

Depth-first search


            
var dirListGraph = new DirectedListGraph<int, edge>(5);
dirListGraph.AddEdge(new UnweightedEdge(0, 1));
dirListGraph.AddEdge(new UnweightedEdge(1, 3));
dirListGraph.AddEdge(new UnweightedEdge(0, 2));
dirListGraph.AddEdge(new UnweightedEdge(0, 3));
dirListGraph.AddEdge(new UnweightedEdge(3, 4));
var bfs = new DepthFirstPathes<int, edge>(dirListGraph, 0);
var path = bfs.PathTo(4).ToArray();
foreach (var vertexId in path)
{
    Console.WriteLine(vertexId);
}

Minimum cuts



var matrixGraph = new MatrixGraph<int, WeightedEdge>(4);
matrixGraph.AddEdge(new WeightedEdge(0, 1, 1));
matrixGraph.AddEdge(new WeightedEdge(1, 2, 4));
matrixGraph.AddEdge(new WeightedEdge(2, 3, 1));
matrixGraph.AddEdge(new WeightedEdge(3, 0, 10));
var minCuts = new MinimumCuts<int, WeightedEdge>(matrixGraph);
foreach (var vertexId in MinimumCut)
{
    Console.WriteLine(vertexId);
}           

Minimal spanning tree



var matrixGraph = new ListGraph<int, WeightedEdge>(6);
g.AddEdge(new WeightedEdge(0, 1, 2));
g.AddEdge(new WeightedEdge(1, 3, 1));
g.AddEdge(new WeightedEdge(2, 4, 3));
g.AddEdge(new WeightedEdge(2, 3, 10));
g.AddEdge(new WeightedEdge(0, 1, 2));
g.AddEdge(new WeightedEdge(3, 5, 2));
g.AddEdge(new WeightedEdge(4, 5, 5));
var mst = new MinimalSpanningTree<int, WeightedEdge>(g);
Console.WriteLine(mst.GetMstWeight()); // prints 13.0       

Strong components


            
var g = new DirectedListGraph<int, UnweightedEdge>(6);
g.AddEdge(new UnweightedEdge(0, 1));
g.AddEdge(new UnweightedEdge(2, 0));
g.AddEdge(new UnweightedEdge(2, 1));
g.AddEdge(new UnweightedEdge(3, 4));
g.AddEdge(new UnweightedEdge(4, 5));
g.AddEdge(new UnweightedEdge(5, 3));
var strongComponents = new StrongComponents<int, edge>(g);     

Floyd-Worshell algorithm (the shortest path)



var g = new ListGraph<int, WeightedEdge>(5);
g.AddEdge(new WeightedEdge(0, 1, 1));
g.AddEdge(new WeightedEdge(0, 2, 1));
g.AddEdge(new WeightedEdge(1, 2, 1));
g.AddEdge(new WeightedEdge(3, 4, 1));
g.AddEdge(new WeightedEdge(1, 4, 1));
var res = g.GetShortestPathesList();    

Dijkstra algorithm (the shortest path)



var m = new DirectedListGraph<int, Weightededge>(6);
m.AddEdge(new WeightedEdge(0, 2, 1));
m.AddEdge(new WeightedEdge(0, 1, 7));
m.AddEdge(new WeightedEdge(0, 5, 4));
m.AddEdge(new WeightedEdge(5, 3, 4));
m.AddEdge(new WeightedEdge(4, 3, 1));
m.AddEdge(new WeightedEdge(3, 2, 2));
m.AddEdge(new WeightedEdge(2, 4, 3));
m.AddEdge(new WeightedEdge(2, 1, 3));
var d = new Dijkstra<int, weightededge>(m, 0);
var path = d.PathTo(3);    

Topological sort


                
var g = new ListGraph<int, WeightedEdge>(4);
g.AddEdge(new WeightedEdge(0, 2, 1));
g.AddEdge(new WeightedEdge(0, 1, 1));
g.AddEdge(new WeightedEdge(1, 3, 1));
g.AddEdge(new WeightedEdge(2, 1, 1));
g.AddEdge(new WeightedEdge(2, 3, 1));
var topSort = new TopologicalSort<int, WeightedEdge>();
topSort.SortGraph(g);
var order = topSort.GetOrder();  

Code map

If you want to understand the whole stucture of the framework, you can look through the code map of the framework.