private void NonTreeEdge(Object sender, EdgeEventArgs<string,Edge<string>> args) { string u, v; if (args.Edge.Source == currentVertex) { u = args.Edge.Source; v = args.Edge.Target; } else { v = args.Edge.Source; u = args.Edge.Target; } Assert.IsFalse(algo.VertexColors[v] == GraphColor.White); if (algo.VisitedGraph.IsDirected) { // cross or back edge Assert.IsTrue(distances[v] <= distances[u] + 1); } else { // cross edge (or going backwards on a tree edge) Assert.IsTrue( distances[v] == distances[u] || distances[v] == distances[u] + 1 || distances[v] == distances[u] - 1 ); } }
private void TreeEdge(Object sender, EdgeEventArgs<int, Edge<int>> args) { int u = args.Edge.Source; int v = args.Edge.Target; Assert.AreEqual(distances[u], currentDistance); this.parents[v] = u; this.distances[v] = distances[u] + 1; }
public static void InitEdge(object sender, EdgeEventArgs arg) { string s = (arg.Edge.Source is MyVertex)? ((MyVertex)arg.Edge.Source).Name : arg.Edge.Source.ID.ToString(); string t = (arg.Edge.Target is MyVertex)? ((MyVertex)arg.Edge.Target).Name : arg.Edge.Target.ID.ToString(); Console.WriteLine("Edge from {0} to {1}", s, t); }
public void FinishEdge(Object sender, EdgeEventArgs args) { NamedEdge e = (NamedEdge)args.Edge; NamedVertex v = (NamedVertex)args.Edge.Target; Console.WriteLine("-- {0}, {1}", e.Name, v.Name ); }
public void InitializeEdge(object sender, EdgeEventArgs args) { // put vertex to uncertain if (!this.edgeNullStates.Contains(args.Edge)) { this.edgeNullStates.Add(args.Edge, NullState.Uncertain); this.vertexNullStates[args.Edge.Source] = NullState.Uncertain; this.vertexNullStates[args.Edge.Target] = NullState.Uncertain; } }
private void TreeEdge(Object sender, EdgeEventArgs <TVertex, TEdge> args) { int sourceDistance; if (!this.distances.TryGetValue(args.Edge.Source, out sourceDistance)) { this.distances[args.Edge.Source] = sourceDistance = 0; } this.distances[args.Edge.Target] = sourceDistance + 1; }
private void TreeEdge(Object sender, EdgeEventArgs <int, Edge <int> > args) { int u = args.Edge.Source; int v = args.Edge.Target; Assert.AreEqual(algo.VertexColors[v], GraphColor.White); Assert.AreEqual(distances[u], currentDistance); parents[v] = u; distances[v] = distances[u] + 1; }
public void ExamineEdge(Object sender, EdgeEventArgs args) { Assert.IsTrue(sender is UndirectedDepthFirstSearchAlgorithm); UndirectedDepthFirstSearchAlgorithm algo = (UndirectedDepthFirstSearchAlgorithm)sender; bool sourceGray = algo.Colors[args.Edge.Source] == GraphColor.Gray; bool targetGray = algo.Colors[args.Edge.Target] == GraphColor.Gray; Assert.IsTrue(sourceGray || targetGray); }
/// <summary> /// Does a depth first search on the vertex u /// </summary> /// <param name="u">vertex to explore</param> /// <exception cref="ArgumentNullException">u cannot be null</exception> public void Visit(IVertex u) { if (u == null) { throw new ArgumentNullException("u"); } IVertex v = null; Colors[u] = GraphColor.Gray; VertexEventArgs uArgs = new VertexEventArgs(u); if (this.DiscoverVertex != null) { DiscoverVertex(this, uArgs); } foreach (IEdge e in VisitedGraph.OutEdges(u)) { EdgeEventArgs eArgs = new EdgeEventArgs(e); if (this.ExamineEdge != null) { ExamineEdge(this, eArgs); } v = e.Target; if (Colors[v] == GraphColor.White) { if (this.TreeEdge != null) { TreeEdge(this, eArgs); } Visit(v); } else if (Colors[v] == GraphColor.Gray) { if (this.BackEdge != null) { BackEdge(this, eArgs); } } else { if (this.ForwardOrCrossEdge != null) { ForwardOrCrossEdge(this, eArgs); } } } Colors[u] = GraphColor.Black; if (this.FinishVertex != null) { FinishVertex(this, uArgs); } }
private void RaiseNewEdgeInRepo(Repo.IEdge edge, NodeViewModel prevVer, NodeViewModel ctrlVer) { var args = new EdgeEventArgs { Edge = edge, PrevVer = prevVer, CtrlVer = ctrlVer }; this.NewEdgeInRepo?.Invoke(this, args); }
/// <summary> /// Let e = (u,v), p[u]=e /// </summary> public void TreeEdge(Object sender, EdgeEventArgs args) { if (args.Edge is ReversedEdge) { this.Successors[args.Edge.Source] = ((ReversedEdge)args.Edge).Wrapped; } else { this.Successors[args.Edge.Source] = args.Edge; } }
void dfs_ForwardOrCrossEdge(object sender, EdgeEventArgs <TVertex, TEdge> e) { // we have touched another tree, updating count and current component int otherComponent = this.componentEquivalences[this.components[e.Edge.Target]]; if (otherComponent != this.currentComponent) { this.componentCount--; this.componentEquivalences[this.currentComponent] = otherComponent; this.currentComponent = otherComponent; } }
private void FinishEdge(Object sender, EdgeEventArgs <TVertex, TEdge> args) { foreach (TEdge edge in this.EdgePredecessors.Values) { if (edge.Equals(args.Edge)) { return; } } this.EndPathEdges.Add(args.Edge); }
public void BlackTarget(Object sender, EdgeEventArgs args) { Assert.IsTrue(sender is BreadthFirstSearchAlgorithm); BreadthFirstSearchAlgorithm algo = (BreadthFirstSearchAlgorithm)sender; Assert.AreEqual(algo.Colors[args.Edge.Target], GraphColor.Black); foreach (IEdge e in algo.VisitedGraph.OutEdges(args.Edge.Target)) { Assert.IsFalse(algo.Colors[e.Target] == GraphColor.White); } }
private void InternalTreeEdge(Object sender, EdgeEventArgs <TVertex, TEdge> args) { bool decreased = Relax(args.Edge); if (decreased) { OnTreeEdge(args.Edge); } else { OnEdgeNotRelaxed(args.Edge); } }
/// <summary> /// Checks for edge relation. /// </summary> /// <param name="sender"></param> /// <param name="args"></param> private void TreeEdge(Object sender, EdgeEventArgs args) { bool decreased = Relax(args.Edge); if (decreased) { OnEdgeRelaxed(args.Edge); } else { OnEdgeNotRelaxed(args.Edge); } }
public static void AddFilterToEdge <T>(object sender, EdgeEventArgs <T> e) where T : IComparable <T> { IEdge <T> edge = e.Edge; if (edge != null) { if (!edge.Properties.ContainsKey("Filter")) { Console.WriteLine("Adding filter to edge {0}", edge); edge.Properties.Add("Filter", "This is a Filter!"); } } }
public void TreeEdge(Object sender, EdgeEventArgs args) { Assert.IsTrue(sender is BreadthFirstSearchAlgorithm); BreadthFirstSearchAlgorithm algo = (BreadthFirstSearchAlgorithm)sender; IVertex u = args.Edge.Source; IVertex v = args.Edge.Target; Assert.AreEqual(algo.Colors[v], GraphColor.White); Assert.AreEqual(Distances[u], CurrentDistance); Parents[v] = u; Distances[v] = Distances[u] + 1; }
SetUp() { IVertex oVertex1 = new Vertex(); IVertex oVertex2 = new Vertex(); IGraph oGraph = new Graph(); oGraph.Vertices.Add(oVertex1); oGraph.Vertices.Add(oVertex2); m_oEdge = new Edge(oVertex1, oVertex2, true); m_oEdgeEventArgs = new EdgeEventArgs(m_oEdge); }
/// <summary> /// Handles the EdgeRemoved event of the Graph control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="Palmmedia.WpfGraph.Core.EdgeEventArgs<TNodeType, TEdgeType>"/> instance containing the event data.</param> private void Graph_EdgeRemoved(object sender, EdgeEventArgs <NodeData, EdgeData> e) { Logger.Debug("Removed edge: " + e.Edge); var visual = this.edge2VisualDictionary[e.Edge]; this.Container.Children.Remove(visual); this.edge2VisualDictionary.Remove(e.Edge); if (e.Edge == this.SelectedElement) { this.SelectedElement = null; } }
private void GrayTarget(Object sender, EdgeEventArgs <string, Edge <string> > args) { string v; if (args.Edge.Source == currentVertex) { v = args.Edge.Target; } else { v = args.Edge.Source; } Assert.AreEqual(algo.VertexColors[v], GraphColor.Gray); }
private void InternalGrayTarget(Object sender, EdgeEventArgs <TVertex, TEdge> args) { bool decreased = Relax(args.Edge); if (decreased) { this.vertexQueue.Update(args.Edge.Target); OnTreeEdge(args.Edge); } else { OnEdgeNotRelaxed(args.Edge); } }
/// <summary> /// Checks for edge relation. /// </summary> /// <param name="sender"></param> /// <param name="args"></param> private void GrayTarget(Object sender, EdgeEventArgs args) { bool decreased = Relax(args.Edge); if (decreased) { this.vertexQueue.Update(args.Edge.Target); OnEdgeRelaxed(args.Edge); } else { OnEdgeNotRelaxed(args.Edge); } }
public static void DisplayEdgeProperties <T>(object sender, EdgeEventArgs <T> e) where T : IComparable <T> { IEdge <T> edge = e.Edge; if (edge != null) { IDictionary <Object, Object> properties = edge.Properties; foreach (KeyValuePair <object, object> pair in properties) { Console.WriteLine("{0} = {1}", (pair.Key != null ? pair.Key.ToString() : "<null>"), (pair.Value != null ? pair.Value.ToString() : "<null>")); } } }
/// <summary> /// Extracts the color tables from the calling algorithm /// </summary> /// <param name="sender"></param> /// <param name="args"></param> protected void GetColors(Object sender, EdgeEventArgs args) { if (sender is IVertexColorizerAlgorithm) { IVertexColorizerAlgorithm algo = (IVertexColorizerAlgorithm)sender; m_Colors = algo.Colors; } if (sender is IEdgeColorizerAlgorithm) { IEdgeColorizerAlgorithm algo = (IEdgeColorizerAlgorithm)sender; m_EdgeColors = algo.EdgeColors; } else if (m_EdgeColors != null) { m_EdgeColors[args.Edge] = GraphColor.Black; } }
private void walker_WeightedTreeEdge(object sender, EdgeEventArgs e) { this.vertexCounts[e.Edge.Target]++; this.edgeCounts[e.Edge]++; this.edgeWeights[e.Edge] *= 0.9; PropertyGridShape shape = (PropertyGridShape)this.netronPanel.Populator.VertexShapes[e.Edge.Source]; shape.TitleBackColor = Color.White; shape = (PropertyGridShape)this.netronPanel.Populator.VertexShapes[e.Edge.Target]; shape.TitleBackColor = Color.LightGreen; shape.Title = this.vertexCounts[e.Edge.Target].ToString(); this.netronPanel.Invalidate(); }
EdgeCollection_EdgeAdded ( Object oSender, EdgeEventArgs oEdgeEventArgs ) { if (oSender == null || !(oSender is IEdgeCollection)) { throw new ApplicationException( "EdgeAdded event provided incorrect oSender argument." ); } m_bEdgeAdded = true; m_oAddedEdge = oEdgeEventArgs.Edge; }
/// <summary> /// Visits vertex s /// </summary> /// <param name="u">vertex to visit</param> public void Visit(IVertex u) { VertexEventArgs uArgs = new VertexEventArgs(u); Colors[u] = GraphColor.Gray; if (DiscoverVertex != null) { DiscoverVertex(this, uArgs); } foreach (IEdge e in VisitedGraph.OutEdges(u)) { EdgeEventArgs eArgs = new EdgeEventArgs(e); if (ExamineEdge != null) { ExamineEdge(this, eArgs); } GraphColor vc = Colors[e.Target]; GraphColor ec = EdgeColors[e]; EdgeColors[e] = GraphColor.Black; if (vc == GraphColor.White) // tree edge { if (TreeEdge != null) { TreeEdge(this, eArgs); } Visit(e.Target); } else if (vc == GraphColor.Gray && ec == GraphColor.White) { if (BackEdge != null) { BackEdge(this, eArgs); } } } Colors[u] = GraphColor.Black; if (FinishVertex != null) { FinishVertex(this, uArgs); } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="args"></param> public void WriteEdge(Object sender, EdgeEventArgs args) { if (m_EdgeColors.Contains(args.Edge)) { m_Edge.Style = GraphvizEdgeStyle.Bold; } else { m_Edge.Style = GraphvizEdgeStyle.Unspecified; } if (EdgeLabels != null) { m_Edge.Label.Value = EdgeLabels[args.Edge].ToString(); } ((GraphvizAlgorithm)sender).Output.Write(m_Edge.ToDot()); }
public void TreeEdge(Object sender, EdgeEventArgs args) { Assert.IsTrue(sender is UndirectedDepthFirstSearchAlgorithm); UndirectedDepthFirstSearchAlgorithm algo = (UndirectedDepthFirstSearchAlgorithm)sender; bool sourceWhite = algo.Colors[args.Edge.Source] == GraphColor.White; bool targetWhite = algo.Colors[args.Edge.Target] == GraphColor.White; Assert.IsTrue(sourceWhite || targetWhite); if (targetWhite) { Parents[args.Edge.Target] = args.Edge.Source; } else { Parents[args.Edge.Source] = args.Edge.Target; } }
/// <summary> /// Checks for edge relation. /// </summary> /// <param name="sender"></param> /// <param name="args"></param> public void TreeEdge(Object sender, EdgeEventArgs args) { bool decreased = Relax(args.Edge); if (decreased) { if (EdgeRelaxed != null) { EdgeRelaxed(this, new EdgeEventArgs(args.Edge)); } } else { if (EdgeNotRelaxed != null) { EdgeNotRelaxed(this, new EdgeEventArgs(args.Edge)); } } }
private void TreeEdge(Object sender, EdgeEventArgs<string,Edge<string>> args) { string u, v; if (args.Edge.Source == currentVertex) { u = args.Edge.Source; v = args.Edge.Target; } else { v = args.Edge.Source; u = args.Edge.Target; } Assert.AreEqual(algo.VertexColors[v], GraphColor.White); Assert.AreEqual(distances[u], currentDistance); parents[v] = u; distances[v] = distances[u] + 1; }
private void TreeEdge(Object sender, EdgeEventArgs <string, Edge <string> > args) { string u, v; if (args.Edge.Source == currentVertex) { u = args.Edge.Source; v = args.Edge.Target; } else { v = args.Edge.Source; u = args.Edge.Target; } Assert.AreEqual(algo.VertexColors[v], GraphColor.White); Assert.AreEqual(distances[u], currentDistance); parents[v] = u; distances[v] = distances[u] + 1; }
private void ExamineEdge(Object sender, EdgeEventArgs<string,Edge<string>> args) { Assert.AreEqual(dfs.VertexColors[args.Edge.Source], GraphColor.Gray); }
private void TreeEdge(Object sender, EdgeEventArgs<string,Edge<string>> args) { Assert.AreEqual(dfs.VertexColors[args.Edge.Target], GraphColor.White); parents[args.Edge.Target] = args.Edge.Source; }
private void BackEdge(Object sender, EdgeEventArgs<string,Edge<string>> args) { Assert.AreEqual(dfs.VertexColors[args.Edge.Target], GraphColor.Gray); }
public void WriteEdge(Object sender, EdgeEventArgs args) { GraphvizWriterAlgorithm algo = (GraphvizWriterAlgorithm)sender; algo.Output.Write(m_Edge.ToDot()); }
private void FowardOrCrossEdge(Object sender, EdgeEventArgs<string,Edge<string>> args) { Assert.AreEqual(dfs.VertexColors[args.Edge.Target], GraphColor.Black); }
private void GrayTarget(Object sender, EdgeEventArgs<string,Edge<string>> args) { string v; if (args.Edge.Source == currentVertex) { v = args.Edge.Target; } else { v = args.Edge.Source; } Assert.AreEqual(algo.VertexColors[v], GraphColor.Gray); }
private void BlackTarget(Object sender, EdgeEventArgs<string,Edge<string>> args) { string u, v; if (args.Edge.Source == currentVertex) { u = args.Edge.Source; v = args.Edge.Target; } else { v = args.Edge.Source; u = args.Edge.Target; } Assert.AreEqual(algo.VertexColors[v], GraphColor.Black); foreach (Edge<string> e in algo.VisitedGraph.AdjacentEdges(v)) { Assert.IsFalse(algo.VertexColors[ (e.Source==v) ? e.Target : e.Source ] == GraphColor.White); } }