public void AddEdgeTargetNotFound(IEdgeMutableGraph g) { IVertex u = g.AddVertex(); IVertex v = g.AddVertex(); g.RemoveVertex(v); IEdge e = g.AddEdge(u, v); }
public void RemoveEdge(IEdgeMutableGraph g) { IVertex v = g.AddVertex(); IVertex u = g.AddVertex(); IEdge e = g.AddEdge(u, v); g.RemoveEdge(e); }
public void AddEdge(IEdgeMutableGraph g) { IVertex v = g.AddVertex(); IVertex u = g.AddVertex(); IEdge e = g.AddEdge(u, v); Assert.AreEqual(e.Source, u); Assert.AreEqual(e.Target, v); }
public void ClearVertexTargetSource(IEdgeMutableGraph g) { IVertex u = g.AddVertex(); IVertex v = g.AddVertex(); g.AddEdge(u, v); g.ClearVertex(v); g.ClearVertex(u); }
public void RemoveEdgeNotFound() { IEdgeMutableGraph g = Graph; IVertex v = g.AddVertex(); IVertex u = g.AddVertex(); IEdge e = g.AddEdge(u, v); g.RemoveEdge(e); g.RemoveEdge(e); }
public void ClearVertexSourceTarget() { IEdgeMutableGraph g = Graph; IVertex v = g.AddVertex(); IVertex u = g.AddVertex(); g.AddEdge(u, v); g.ClearVertex(u); g.ClearVertex(v); }
public void AddRemoveVertexNotFound(IEdgeMutableGraph g) { IVertex v = g.AddVertex(); g.RemoveVertex(v); g.RemoveVertex(v); }
public void AddRemoveVertex() { IEdgeMutableGraph g = Graph; IVertex v = g.AddVertex(); g.RemoveVertex(v); }
public void AddEdgeTargetNotFound() { IEdgeMutableGraph g = Graph; IEdgeMutableGraph g2 = Graph; IVertex v = g.AddVertex(); IVertex u = g2.AddVertex(); IEdge e = g.AddEdge(v, u); }
public void AddEdgeSourceNotFound() { IEdgeMutableGraph g = Graph; IEdgeMutableGraph g2 = Graph; IVertex v = g.AddVertex(); IVertex u = g2.AddVertex(); IEdge e = g.AddEdge(u, v); }
public void AddRemoveVertexNotFound() { IEdgeMutableGraph g = Graph; IEdgeMutableGraph g2 = Graph; IVertex v = g2.AddVertex(); g.RemoveVertex(v); }
/// <summary> /// Generates a random graph /// </summary> /// <param name="g">Graph to fill</param> /// <param name="V">number of vertices</param> /// <param name="E">number of edges</param> /// <param name="rnd">random generator</param> /// <param name="selfEdges">self edges allowed</param> public static void Graph( IEdgeMutableGraph g, int V, int E, Random rnd, bool selfEdges ) { if (g == null) { throw new ArgumentNullException("g"); } if (rnd == null) { throw new ArgumentNullException("random generator"); } IVertex a = null; IVertex b = null; // When parallel edges are not allowed, we create a new graph which // does not allow parallel edges, construct it and copy back. // This is not efficient if 'g' already disallow parallel edges, // but that's task for later. if (!g.AllowParallelEdges) { throw new Exception("not implemented"); } else { for (int i = 0; i < V; ++i) { g.AddVertex(); } for (int j = 0; j < E; ++j) { a = Vertex((IVertexListGraph)g, rnd); do { b = Vertex((IVertexListGraph)g, rnd); }while (selfEdges == false && a == b); g.AddEdge(a, b); } } }
/// <summary> /// Generates a random graph /// </summary> /// <param name="g">Graph to fill</param> /// <param name="vertexCount">number of vertices</param> /// <param name="edgeCount">number of edges</param> /// <param name="rnd">random generator</param> /// <param name="selfEdges">self edges allowed</param> public static void Graph( IEdgeMutableGraph g, int vertexCount, int edgeCount, Random rnd, bool selfEdges ) { if (g == null) { throw new ArgumentNullException("g"); } if (rnd == null) { throw new ArgumentNullException("random generator"); } IVertex a = null; IVertex b = null; for (int i = 0; i < vertexCount; ++i) { g.AddVertex(); } int j = 0; while (j < edgeCount) { a = Vertex((IVertexListGraph)g, rnd); do { b = Vertex((IVertexListGraph)g, rnd); }while (selfEdges == false && a == b); try { g.AddEdge(a, b); ++j; } catch (Exception) {} } }
/// <summary> /// Clones the <paramref name="source"/> to <paramref name="target"/> and /// reverses the edges. /// </summary> /// <remarks> /// <para> /// Use this class to create clone of different graphs with possible different /// provider types. /// </para> /// <para> /// The <see cref="CloneVertex"/> and <see cref="CloneEdge"/> events can be /// used to copy the custom properties /// attached to each vertex and edge. /// </para> /// </remarks> public void ReversedClone(IVertexAndEdgeListGraph source, IEdgeMutableGraph target) { VertexVertexDictionary vertexMap = new VertexVertexDictionary(); // copy vertices foreach (IVertex v in source.Vertices) { IVertex vc = target.AddVertex(); // clone properties OnCloneVertex(v, vc); // store in table vertexMap[v] = vc; } // copy edges foreach (IEdge e in source.Edges) { IEdge ec = target.AddEdge(vertexMap[e.Target], vertexMap[e.Source]); // cone properties OnCloneEdge(e, ec); } }
/// <summary> /// Makes a copy of the source graph to the clone graph. /// </summary> /// <param name="source">source graph</param> /// <param name="target">clone graph</param> public void Clone(IVertexAndEdgeListGraph source, IEdgeMutableGraph target) { VertexVertexDictionary vertexMap = new VertexVertexDictionary(); // copy vertices foreach(IVertex v in source.Vertices) { IVertex vc = target.AddVertex(); // clone properties OnCloneVertex(v,vc); // store in table vertexMap[v]=vc; } // copy edges foreach(IEdge e in source.Edges) { IEdge ec = target.AddEdge(vertexMap[e.Source], vertexMap[e.Target]); // cone properties OnCloneEdge(e,ec); } }
public void AddEdgeSourceNotFound(IEdgeMutableGraph g) { IVertex u = g.AddVertex(); g.RemoveVertex(u); IVertex v = g.AddVertex(); IEdge e = g.AddEdge(u,v); }
public void AddEdge(IEdgeMutableGraph g) { IVertex v = g.AddVertex(); IVertex u = g.AddVertex(); IEdge e = g.AddEdge(u,v); Assert.AreEqual(e.Source,u); Assert.AreEqual(e.Target,v); }
public void RemoveEdgeNotFound(IEdgeMutableGraph g) { IVertex v = g.AddVertex(); IVertex u = g.AddVertex(); IEdge e = g.AddEdge(u,v); g.RemoveEdge(e); g.RemoveEdge(e); }
public void ClearVertexTargetSource(IEdgeMutableGraph g) { IVertex u = g.AddVertex(); IVertex v = g.AddVertex(); g.AddEdge(u,v); g.ClearVertex(v); g.ClearVertex(u); }
/// <summary> /// Generates a random graph /// </summary> /// <param name="g">Graph to fill</param> /// <param name="vertexCount">number of vertices</param> /// <param name="edgeCount">number of edges</param> /// <param name="rnd">random generator</param> /// <param name="selfEdges">self edges allowed</param> public static void Graph( IEdgeMutableGraph g, int vertexCount, int edgeCount, Random rnd, bool selfEdges ) { if (g == null) throw new ArgumentNullException("g"); if (rnd == null) throw new ArgumentNullException("random generator"); IVertex a=null; IVertex b=null; for (int i = 0; i < vertexCount; ++i) g.AddVertex(); int j=0; while(j<edgeCount) { a = Vertex((IVertexListGraph)g, rnd); do { b = Vertex((IVertexListGraph)g, rnd); } while (selfEdges == false && a == b); try { g.AddEdge(a, b); ++j; } catch(Exception) {} } }
/// <summary> /// Generates a random graph /// </summary> /// <param name="g">Graph to fill</param> /// <param name="V">number of vertices</param> /// <param name="E">number of edges</param> /// <param name="rnd">random generator</param> /// <param name="selfEdges">self edges allowed</param> public static void Graph( IEdgeMutableGraph g, int V, int E, Random rnd, bool selfEdges ) { if (g == null) throw new ArgumentNullException("g"); if (rnd == null) throw new ArgumentNullException("random generator"); IVertex a=null; IVertex b=null; // When parallel edges are not allowed, we create a new graph which // does not allow parallel edges, construct it and copy back. // This is not efficient if 'g' already disallow parallel edges, // but that's task for later. if (!g.AllowParallelEdges) { throw new Exception("not implemented"); } else { for (int i = 0; i < V; ++i) g.AddVertex(); for (int j = 0; j < E; ++j) { a = Vertex((IVertexListGraph)g, rnd); do { b = Vertex((IVertexListGraph)g, rnd); } while (selfEdges == false && a == b); g.AddEdge(a, b); } } }