public void BalanceTwice() { g = GraphFactory.UnBalancedFlow(); algo = new GraphBalancerAlgorithm(g, Traversal.FirstVertex(g), Traversal.FirstVertex(g)); algo.Balance(); algo.Balance(); }
public void ConstructorWithSinkNotPartOfTheGraph() { g = GraphFactory.UnBalancedFlow(); Vertex v = new Vertex(); new GraphBalancerAlgorithm(g, Traversal.FirstVertex(g), v); }
public void ConstructorWithNullSink() { g = GraphFactory.UnBalancedFlow(); Vertex v = new Vertex(); new GraphBalancerAlgorithm(g, Traversal.FirstVertex(g), null); }
private void breadthFirstSearchItem_Click(object sender, System.EventArgs e) { if (this.netronPanel.Graph == null) { throw new Exception("Generate a graph first"); } if (this.netronPanel.Populator == null) { throw new Exception("Populator should not be null."); } ResetVertexAndEdgeColors(); // create algorithm this.edgeColors = new EdgeColorDictionary(); foreach (IEdge edge in this.netronPanel.Graph.Edges) { this.edgeColors[edge] = GraphColor.White; } this.vertexColors = new VertexColorDictionary(); BreadthFirstSearchAlgorithm bfs = new BreadthFirstSearchAlgorithm( this.netronPanel.Graph, new VertexBuffer(), this.vertexColors); // create tracer LayoutAlgorithmTraverVisitor tracer = new LayoutAlgorithmTraverVisitor(this.netronPanel.Populator); // link to algo bfs.RegisterTreeEdgeBuilderHandlers(tracer); bfs.RegisterVertexColorizerHandlers(tracer); bfs.TreeEdge += new EdgeEventHandler(dfs_TreeEdge); bfs.NonTreeEdge += new EdgeEventHandler(dfs_BackEdge); bfs.BlackTarget += new EdgeEventHandler(dfs_ForwardOrCrossEdge); // add handler to tracers tracer.UpdateVertex += new ShapeVertexEventHandler(tracer_UpdateVertex); tracer.UpdateEdge += new ConnectionEdgeEventHandler(tracer_UpdateEdge); // running algorithm VertexMethodCaller vm = new VertexMethodCaller( new ComputeVertexDelegate(bfs.Compute), Traversal.FirstVertex(this.netronPanel.Graph) ); Thread thread = new Thread(new ThreadStart(vm.Run)); thread.Start(); }
/// <summary> /// Computes the eulerian trails /// </summary> public void Compute() { CurrentVertex = Traversal.FirstVertex(VisitedGraph); // start search Search(CurrentVertex); if (CircuitAugmentation()) { return; // circuit is found } do { if (!Visit()) { break; // visit edges and build path } if (CircuitAugmentation()) { break; // circuit is found } } while(true); }
public void UnBalanceBeforeBalancing() { g = GraphFactory.UnBalancedFlow(); algo = new GraphBalancerAlgorithm(g, Traversal.FirstVertex(g), Traversal.FirstVertex(g)); algo.UnBalance(); }