/// <summary> /// Executes edge dfs /// </summary> /// <param name="g"></param> public void TestAllActions(IVertexAndEdgeListGraph g, string path) { // Testing dfs all apth DepthFirstSearchAlgorithm dfs = new DepthFirstSearchAlgorithm(g); PredecessorRecorderVisitor visv = new PredecessorRecorderVisitor(); dfs.RegisterPredecessorRecorderHandlers(visv); IVertex s0 = Traversal.FirstVertexIf(g.Vertices, new NameEqualPredicate("S0")); dfs.Compute(s0); Console.WriteLine("vertex paths"); foreach(EdgeCollection ec in visv.AllPaths()) { foreach(IEdge edge in ec) { Console.WriteLine("{0}->{1}, {2}", ((NamedVertex)edge.Source).Name, ((NamedVertex)edge.Target).Name, ((NamedEdge)edge).Name ); } Console.WriteLine(); } // end of dfs test GraphvizAlgorithm gw = RenderActions(g,path); // The all action algorithms EdgeDepthFirstSearchAlgorithm edfs = CreateEdgeDfs(g); // add tracer AlgorithmTracerVisitor vis = AddTracer(edfs,path); // add predecessor recorder EdgePredecessorRecorderVisitor erec = AddPredecessorRecorder(edfs); // computing all actions edfs.Compute(s0); // display end path edges OutputEndPathEdges(erec); // display all actions path OutputAllActions(erec,gw,path); }
public RunPipeCollection AllTestPipes() { if (this.graph.VerticesCount == 1) { // only the root vertex return new RunPipeCollection(); } DepthFirstSearchAlgorithm dfs = new DepthFirstSearchAlgorithm( this.graph ); // attach leaf recorder PredecessorRecorderVisitor pred = new PredecessorRecorderVisitor(); dfs.RegisterPredecessorRecorderHandlers(pred); dfs.Compute(this.Root); // create pipies RunPipeCollection pipes = new RunPipeCollection(); foreach(EdgeCollection edges in pred.AllPaths()) { RunPipe pipe = new RunPipe(this.Fixture); foreach(IEdge e in edges) { pipe.Invokers.Add((RunInvokerVertex)e.Target); } pipes.Add(pipe); } return pipes; }
public EdgeCollectionCollection GetAllEdgePaths() { if (this.graph.VerticesCount==0) return new EdgeCollectionCollection(); DepthFirstSearchAlgorithm efs = new DepthFirstSearchAlgorithm(this.graph); PredecessorRecorderVisitor vis =new PredecessorRecorderVisitor(); efs.RegisterPredecessorRecorderHandlers(vis); // get root vertex efs.Compute(this.Graph.Root); return vis.AllPaths(); }