public void GraphModeChanged(GraphMode mode) { GraphMode = mode; NewEdge = new NewEdge(); StartAlgorithm = new StartAlgorithm(); }
public void RunAlgorithm(Options options, StartAlgorithm startAlgorithm, Graph graph, AlgoExplain algoExplain, ref List <List <GraphObject> > playAlgorithm) { Options = options; StartAlgorithm = startAlgorithm; Graph = graph; AlgoExplain = algoExplain; PlayAlgorithm = playAlgorithm; playAlgorithm.Clear(); AlgoExplain.Explanations.Clear(); AlgoExplain.Counter = 0; PlayAlgorithm.Add(new List <GraphObject>()); foreach (Node node in Graph.Nodes) { PlayAlgorithm[AlgoExplain.Counter].Add(new Node(node, options.Default)); } foreach (Edge edge in Graph.Edges) { PlayAlgorithm[AlgoExplain.Counter].Add(new Edge(edge, options.Default, "")); } MaxId = Graph.Nodes.Max(n => n.Id); Increment(); switch (StartAlgorithm.Algorithm) { case Algorithm.Kruskal: Kruskal(); break; case Algorithm.BFS: BFS(); break; case Algorithm.DFS: DFS(); break; case Algorithm.Dijkstra: Dijkstra(); break; case Algorithm.DijkstraPath: DijkstraPath(); break; case Algorithm.MaxFlow: FordFulkerson(); break; case Algorithm.Degree: Degree(); break; case Algorithm.DegreeCentrality: DegreeCentrality("both"); break; case Algorithm.InDegreeCentrality: DegreeCentrality("in"); break; case Algorithm.OutDegreeCentrality: DegreeCentrality("out"); break; case Algorithm.Articulation: Articulation(); break; } StartAlgorithm.Done = true; AlgoExplain.MaxCounter = AlgoExplain.Counter; AlgoExplain.Counter = 0; }