/// <summary> /// Clones this graph. /// </summary> internal DiGraph <T> Clone() { var newGraph = new DiGraph <T>(); foreach (var vertex in Vertices) { newGraph.AddVertex(vertex.Key); } foreach (var vertex in Vertices) { foreach (var edge in vertex.Value.OutEdges) { newGraph.AddEdge(vertex.Value.Value, edge.Value); } } return(newGraph); }
public static DiGraph <string> GetDiGraph(IEnumerable <NodeModel> nodes, IEnumerable <LinkModel> links) { var resGraph = new DiGraph <string>(); foreach (var nodeModel in nodes) { resGraph.AddVertex(nodeModel.Key); } foreach (var link in links) { if (link.IsOriented) { resGraph.AddEdge(link.From, link.To); } else { resGraph.AddEdge(link.From, link.To); resGraph.AddEdge(link.To, link.From); } } return(resGraph); }