public void AddEgde(IEdge edge) { lock (AllEdgesLock) { AllEdges.Add(edge); } }
public void AddEdge(int startVertexId, int endVertexId, int weight) { if (!AllVertexIndices.ContainsKey(startVertexId)) { AllVertexIndices[startVertexId] = true; } if (!AllVertexIndices.ContainsKey(endVertexId)) { AllVertexIndices[endVertexId] = true; } AllEdges.Add(new GraphEdge(startVertexId, endVertexId, weight)); }
//this handles all the edge select, add, remove commands a user would need public Edge AddEdges(Node StartNode, Node EndNode, String Label = "") { //construct edge object Edge edge = this.gameObject.AddComponent <Edge>(); edge.StartNode = StartNode; edge.EndNode = EndNode; StartNode.EdgesOut.Add(edge.ID, edge); EndNode.EdgesIn.Add(edge.ID, edge); AllEdges.Add(edge.ID, edge); //FlatGraph.addEdges(edge); return(edge); }
/// <summary> /// /// </summary> /// <param name="vertex"></param> public void AddVertex(Vertex <T> vertex) { if (AllVertex.ContainsKey(vertex.Id)) { return; } AllVertex.Add(vertex.Id, vertex); foreach (var e in vertex.GetAdjEdges()) { AllEdges.Add(e); NumberOfEdges++; } NumberOfVertices++; }
public void AddEdge(long id1, long id2, int weight) { Vertex <T> v1 = null; Vertex <T> v2 = null; if (!AllVertex.ContainsKey(id1)) { v1 = new Vertex <T>(id1); AddVertex(v1); } else { v1 = AllVertex[id1]; } if (!AllVertex.ContainsKey(id2)) { v2 = new Vertex <T>(id2); AddVertex(v2); } else { v2 = AllVertex[id2]; } Edge <T> e = new Edge <T>(v1, v2, IsDirected, weight); AllEdges.Add(e); v1.AddAdjacentVertex(e, v2); if (!IsDirected) { v2.AddAdjacentVertex(e, v1); } NumberOfEdges++; }
public void AddEdge(int st, int end, int weight) { AllEdges.Add(new Edge(st, end, weight)); AllVertices[st] = true; AllVertices[end] = true; }