public static PSEdgeNode ToPsEdgeNode(this EdgeNode edgeNode) { return(new PSEdgeNode { IpAddressGroups = edgeNode.IpAddressGroups.Select(i => i.ToPsIpAddressGroup()).ToList() }); }
public void TraverseAllAdjacents() { if (this.vertexList.Count == 0) { XxdwDebugger.Log("No vertex!"); return; } foreach (VertexNode vn in this.vertexList) { string str = "Vertex: (" + (vn.Cell % 144) + "," + (vn.Cell / 144) + ") -> ("; EdgeNode p = vn.FirstEdge; while (p != null) { str += (this.vertexList[p.AdjacentVertex].Cell % 144) + "," + this.vertexList[p.AdjacentVertex].Cell / 144 + " -> "; /*Edge edge = p.EdgeLink; * foreach (int e in edge.Spots) * { * XxdwDebugger.Log("" + e + ","); * }*/ p = p.Next; } XxdwDebugger.Log(str + "\n"); } }
public void AddNode(int yMin, EdgeNode node) { if (Count == 0 || yMin > this[Count - 1].yMin) { EdgeBucket bucket = new EdgeBucket(yMin); bucket.AddNode(node); Add(bucket); } else { for (int tIndex = 0; tIndex < Count; tIndex++) { int cyMin = this[tIndex].yMin; if (yMin < cyMin) { EdgeBucket bucket = new EdgeBucket(yMin); bucket.AddNode(node); Insert(tIndex, bucket); break; } else if (yMin == cyMin) { this[tIndex].AddNode(node); break; } } } }
public void displayAdjList() { Console.WriteLine(); Console.WriteLine("***********Adjacency List***********"); EdgeNode current = null; EdgeNode nextInList = null; for (int i = 1; i < graphSize; i++) { current = adjList[i].head; if (current.next != null) { nextInList = current.next; } Console.WriteLine("Node: {0}, Description:{1}", current.adjGraphNode, adjList[i].description); while (current != null && nextInList != null) { Console.Write(current.adjGraphNode); while (nextInList != null) { string line = "->" + nextInList.adjGraphNode; Console.Write(line); nextInList = nextInList.next; } } Console.WriteLine(); } }
/// <summary> /// This method adds the element if it doesn't exist. /// </summary> /// <param name="position"></param> /// <param name="element"></param> public void Add(int position, EdgeNode element) { if (!this.Dictionary.ContainsKey(position)) { this.Dictionary.Add(position, element); } }
public void AddEdge(Route route) { var node = new EdgeNode(_airports[route.DESTINATION_CODE], _vertices[_airports[route.SOURCE_CODE]], route); _vertices[_airports[route.SOURCE_CODE]] = node; E++; }
public void addEdge(int v, int w) { EdgeNode node = new EdgeNode(w, vertices[v]); vertices[v] = node; E++; }
protected override sealed void Process(Graph graph, int startVertex) { _discovered[startVertex] = true; _processingQueue.Enqueue(startVertex); while (_processingQueue.Count > 0) { int vertex = _processingQueue.Dequeue(); ProcessVertexEarly(vertex); for (EdgeNode edge = graph._edges[vertex]; edge != null; edge = edge.Next) { int endVertex = edge.Value; if (!_processed[endVertex]) { ProcessEdge(vertex, endVertex); } if (!_discovered[endVertex]) { _discovered[endVertex] = true; _processingQueue.Enqueue(endVertex); _parent[endVertex] = vertex; } } ProcessVertexLate(vertex); } }
/// <summary> /// Parses edge expression. /// First parsing anonymous edge is tried and then edges that define variables. /// </summary> /// <returns> A chain of vertex/edge nodes. </returns> static private Node ParseEdge(ref int position, List <Token> tokens) { EdgeNode edgeNode = null; edgeNode = (EdgeNode)TryParseEmptyEdge(ref position, tokens); if (edgeNode == null) { edgeNode = (EdgeNode)ParseEdgeWithMatchVariable(ref position, tokens); if (edgeNode == null) { return(null); } } Node vertexNode = ParseVertex(ref position, tokens); if (vertexNode != null) { edgeNode.AddNext(vertexNode); } else { ThrowError("Match parser", "Expected Vertex.", position, tokens); } return(edgeNode); }
public void AddEdge(int v, int w) { var node = new EdgeNode(w, _vertices[v]); _vertices[v] = node; E++; }
// 按逆时针排序插入, compare(a, b) < 0 表示a -> b为逆时针 private void InsertEdgeNode(int vertexIndex, EdgeNode edgeNode, FuncCompareEdgeByRadian compare) { EdgeNode p = this.vertexList[vertexIndex].FirstEdge, q = null; //string str = "compare: (" + (this.vertexList[vertexIndex].Cell % 144) + "," + (this.vertexList[vertexIndex].Cell / 144) + ") ->"; //str += "(" + (this.vertexList[edgeNode.AdjacentVertex].Cell % 144) + "," + (this.vertexList[edgeNode.AdjacentVertex].Cell / 144) + ") with "; while (p != null) { int rs = compare(edgeNode.EdgeLink, p.EdgeLink); //str += "(" + (this.vertexList[p.AdjacentVertex].Cell % 144) + "," + (this.vertexList[p.AdjacentVertex].Cell / 144) + ")" + "rs=" + rs; if (rs > 0) { break; } q = p; p = p.Next; } //if (this.vertexList[vertexIndex].Cell == 11038) //{ // XxdwDebugger.Log(str); //} if (q == null) { this.vertexList[vertexIndex].FirstEdge = edgeNode; } else { q.Next = edgeNode; } edgeNode.Next = p; this.vertexList[vertexIndex].Degree++; }
//https://api.happynodes.f27.ventures/redis/edges public async Task <IList <EdgeNode> > GetEdges() { var result = await _restClient.GetAsync(EdgesEndpoint).ConfigureAwait(false); var data = await result.Content.ReadAsStringAsync(); return(EdgeNode.FromJson(data)); //TODO DTO }
public void add(int father, int son) //添加两个序号的Feature间的父子关系 { EdgeNode node = new EdgeNode(); node.adjvex = son; node.next = AdjList[father].firstedge; AdjList[father].firstedge = node; }
private void insertEdge(int fromNode, int toNode) { EdgeNode n = new EdgeNode(); n.adjGraphNode = toNode; n.next = null; n.next = adjList[fromNode].head.next; adjList[fromNode].head.next = n; }
public void RemoveNode(int yMin, EdgeNode node) { for (int tIndex = 0; tIndex < Count; tIndex++) { if (this[tIndex].yMin == yMin) { this[tIndex].RemoveNode(node); break; } } }
/// <summary> /// This method could throw an error if the element doesn't exist yet. /// </summary> /// <param name="position"></param> /// <param name="element"></param> public void Update(int position, EdgeNode element) { if (!this.Dictionary.ContainsKey(position)) { this.Dictionary.Add(position, element); } else { this.Dictionary[position] = element; } }
public IEnumerable <int> adjacents(int v) { List <int> adjacents = new List <int>(); EdgeNode node = vertices[v]; while (node != null) { adjacents.Add(node.v); node = node.next; } return(adjacents); }
/// <summary> /// 获取边在顶点所有边中的序号 /// </summary> /// <param name="vn">顶点</param> /// <param name="e">边</param> public int GetEdgeNumber(VertexNode vn, Edge e) { EdgeNode p = vn.FirstEdge; int which = 0; while (p != null && p.EdgeLink != e) { p = p.Next; which++; } return(which); }
//add edge public void AddEdge(string A, string B) //adds an edge between A and B { // Cases where node is trying to connect to itself if (A.Equals(B)) { Console.WriteLine("Can't connect to itself!"); return; } // Create two nodes each holding the first and second // vertex labels VertexNode node1 = FindVertex(A); VertexNode node2 = FindVertex(B); if (node1 == null) { Console.WriteLine("First vertex doesn't exist!"); } if (node2 == null) { Console.WriteLine("Second vertex doesn't exist!"); } EdgeNode temp = new EdgeNode(node2); if (node1.firstEdge == null) { node1.firstEdge = temp; } else { EdgeNode current = node1.firstEdge; while (current.nextEdge != null) { if (current.endVertex.Label.Equals(B)) { Console.WriteLine("Edge exists!"); } current = current.nextEdge; } if (current.endVertex.Label.Equals(B)) { Console.WriteLine("Edge exists!"); return; } current.nextEdge = temp; } }
private void InsertEdge(int x, int y, int weight, bool directed) { _edges[x] = new EdgeNode(y, weight) { Next = _edges[x] }; if (directed) { nedges++; } else { InsertEdge(y, x, weight, true); } }
public void PrintGraph() { for (int i = 0; i < _edges.Length; i++) { if (_edges[i] == null) { continue; } Console.Write("{0}: ", i); for (EdgeNode edge = _edges[i]; edge != null; edge = edge.Next) { Console.Write("{0}->{1} ", i, edge.Value); } Console.WriteLine(); } }
private void dfsRecursive(int vertex) { adjList[vertex].visited = true; Console.Write("{0} ", vertex); int w = vertex; EdgeNode n = null; if (adjList[vertex].head.next != null) { n = adjList[vertex].head.next; w = n.adjGraphNode; } if (!adjList[w].visited) { dfsRecursive(w); } }
public void WhenDirected_For_12Edge_21Edge_IsNotPresent() { graph.ReadGraph(points, true); bool found = false; EdgeNode edge = graph.Edges[2]; while (edge != null && found == false) { if (edge.YValue == 1) { found = true; } else { edge = edge.Next; } } Assert.IsFalse(found); }
public void Prim() { GraphTree tree = new GraphTree(); bool[] inTree = new bool[MaxV + 1]; int[] weights = new int[MaxV + 1]; int[] parent = new int[MaxV + 1]; for (int j = 0; j <= 10; j++) { weights[j] = int.MaxValue; } int i = 1; while (!inTree[i]) { inTree[i] = true; // Find lowest weight for edges of newly processed vertex. for (EdgeNode edge = _edges[i]; edge != null; edge = edge.Next) { int value = edge.Value; int weight = edge.Weight; if (!inTree[value] && weights[value] > weight) { weights[value] = weight; parent[value] = i; } } // Choose the lowest non-included edge int lowest = int.MaxValue; for (int j = 0; j <= 10; j++) { if (!inTree[j] && weights[j] < lowest) { lowest = weights[j]; i = j; } } } }
//remove edge public void RemoveEdge(string A, string B) { // Assign node to current variable by using // the FindVertex method VertexNode current = FindVertex(A); // If there is no start vertex if (current == null) { Console.WriteLine("There is no starting vertex!"); return; } // If the edge is empty... if (current.firstEdge == null) { Console.WriteLine("Edge doesn't exist!"); return; } if (current.firstEdge.endVertex.Label.Equals(B)) { // if the edge that's going to be deleted is pointing to // current, then delete current.firstEdge = current.firstEdge.nextEdge; return; } // Delete using edge node EdgeNode deleteMe = current.firstEdge; while (deleteMe.nextEdge != null) { if (deleteMe.nextEdge.endVertex.Label.Equals(B)) { deleteMe.nextEdge = deleteMe.nextEdge.nextEdge; return; } deleteMe = deleteMe.nextEdge; } // When edge does not exist Console.WriteLine("No edges!"); }
public bool AddEdge(int cell1, int cell2, float weight, int[] spots, string identifer, FuncCompareEdgeByRadian compare) { if (cell1 > cell2) { int temp = cell1; cell1 = cell2; cell2 = temp; } if (FindEdge(cell1, cell2) >= 0) { XxdwDebugger.Log("The edge already exists."); return(false); } Edge edge = new Edge(cell1, cell2, weight, spots, identifer); this.edgeList.Add(edge); int index1 = FindVertex(cell1); if (index1 < 0) { index1 = this.vertexList.Count; this.vertexList.Add(new VertexNode(cell1)); } int index2 = FindVertex(cell2); if (index2 < 0) { index2 = this.vertexList.Count; this.vertexList.Add(new VertexNode(cell2)); } EdgeNode edgeNode1 = new EdgeNode(index2, edge); InsertEdgeNode(index1, edgeNode1, compare); EdgeNode edgeNode2 = new EdgeNode(index1, edge); InsertEdgeNode(index2, edgeNode2, compare); return(true); }
/// <summary> /// Parses an edge expression with an enclosed variable definition. /// </summary> /// <returns> Null on fault match or edge node.</returns> private static Node ParseEdgeWithMatchVariable(ref int position, List <Token> tokens) { EdgeNode edgeNode = null; if (CheckToken(position, Token.TokenType.Dash, tokens)) { position++; edgeNode = (EdgeNode)ParseOutAnyEdge(ref position, tokens); } else if (CheckToken(position, Token.TokenType.Less, tokens)) { position++; edgeNode = (EdgeNode)ParseInEdge(ref position, tokens); } else { edgeNode = null; } return(edgeNode); }
private EdgeNode Relate(string parentKey, string childKey, EnumRelations related) { var key = parentKey + "." + childKey + "." + related.ToString(); if (_edgeKeyToIndex.ContainsKey(key)) { return(_edges[_edgeKeyToIndex[key]]); } var relatedEdge = new EdgeNode { ParentKey = parentKey, ChildKey = childKey, Related = related }; if (_nodeKeyToIndex.ContainsKey(parentKey)) { relatedEdge.Source = _nodeKeyToIndex[parentKey]; } if (_nodeKeyToIndex.ContainsKey(childKey)) { relatedEdge.Target = _nodeKeyToIndex[childKey]; } _edges.Add(relatedEdge.Id, relatedEdge); return(relatedEdge); }
public void Execute() { EdgeNode[] edgePair = new EdgeNode[CandidateGraph.MaxV]; }
// Display an edge node (no recursion). private void DisplayNode(EdgeNode pNode) { SpawnNode(pNode); }
private static void insert_bound( LmtNode lmt_node, EdgeNode e) { if( lmt_node.first_bound == null ) { /* Link node e to the tail of the list */ lmt_node.first_bound = e ; } else { bool done = false ; EdgeNode prev_bound = null ; EdgeNode current_bound = lmt_node.first_bound ; while( !done ) { /* Do primary sort on the x field */ if (e.bot.X < current_bound.bot.X) { /* Insert a new node mid-list */ if( prev_bound == null ) { lmt_node.first_bound = e ; } else { prev_bound.next_bound = e ; } e.next_bound = current_bound ; // EdgeNode existing_bound = current_bound ; // current_bound = e ; // current_bound.next_bound = existing_bound ; // if( lmt_node.first_bound == existing_bound ) // { // lmt_node.first_bound = current_bound ; // } done = true ; } else if (e.bot.X == current_bound.bot.X) { /* Do secondary sort on the dx field */ if (e.dx < current_bound.dx) { /* Insert a new node mid-list */ if( prev_bound == null ) { lmt_node.first_bound = e ; } else { prev_bound.next_bound = e ; } e.next_bound = current_bound ; // EdgeNode existing_bound = current_bound ; // current_bound = e ; // current_bound.next_bound = existing_bound ; // if( lmt_node.first_bound == existing_bound ) // { // lmt_node.first_bound = current_bound ; // } done = true ; } else { /* Head further down the list */ if( current_bound.next_bound == null ) { current_bound.next_bound = e ; done = true ; } else { prev_bound = current_bound ; current_bound = current_bound.next_bound ; } } } else { /* Head further down the list */ if( current_bound.next_bound == null ) { current_bound.next_bound = e ; done = true ; } else { prev_bound = current_bound ; current_bound = current_bound.next_bound ; } } } } }
public void addNode( double x, double y ) { EdgeNode node = new EdgeNode(); node.vertex.X = (float) x ; node.vertex.Y = (float) y ; m_List.Add( node ); }
public PointF point = new PointF(); /* Point of intersection */ #endregion Fields #region Constructors public ItNode( EdgeNode edge0, EdgeNode edge1, double x, double y, ItNode next ) { this.ie[0] = edge0 ; this.ie[1] = edge1 ; this.point.X = (float) x ; this.point.Y = (float) y ; this.next = next ; }
public double xt; /* Scanbeam top x coordinate */ #endregion Fields #region Constructors public StNode( EdgeNode edge, StNode prev ) { this.edge = edge ; this.xb = edge.xb ; this.xt = edge.xt ; this.dx = edge.dx ; this.prev = prev ; }
private static void add_edge_to_aet( AetTree aet , EdgeNode edge ) { if ( aet.top_node == null ) { /* Append edge onto the tail end of the AET */ aet.top_node = edge; edge.prev = null ; edge.next= null; } else { EdgeNode current_edge = aet.top_node ; EdgeNode prev = null ; bool done = false ; while( !done ) { /* Do primary sort on the xb field */ if (edge.xb < current_edge.xb) { /* Insert edge here (before the AET edge) */ edge.prev= prev; edge.next= current_edge ; current_edge.prev = edge ; if( prev == null ) { aet.top_node = edge ; } else { prev.next = edge ; } // if( current_edge == aet.top_node ) // { // aet.top_node = edge ; // } // current_edge = edge ; done = true; } else if (edge.xb == current_edge.xb) { /* Do secondary sort on the dx field */ if (edge.dx < current_edge.dx) { /* Insert edge here (before the AET edge) */ edge.prev= prev; edge.next= current_edge ; current_edge.prev = edge ; if( prev == null ) { aet.top_node = edge ; } else { prev.next = edge ; } // if( current_edge == aet.top_node ) // { // aet.top_node = edge ; // } // current_edge = edge ; done = true; } else { /* Head further into the AET */ prev = current_edge ; if( current_edge.next == null ) { current_edge.next = edge ; edge.prev = current_edge ; edge.next = null ; done = true ; } else { current_edge = current_edge.next ; } } } else { /* Head further into the AET */ prev = current_edge ; if( current_edge.next == null ) { current_edge.next = edge ; edge.prev = current_edge ; edge.next = null ; done = true ; } else { current_edge = current_edge.next ; } } } } }
private static ItNode add_intersection( ItNode it_node, EdgeNode edge0, EdgeNode edge1, double x, double y) { if (it_node == null) { /* Append a new node to the tail of the list */ it_node = new ItNode( edge0, edge1, x, y, null ); } else { if ( it_node.point.Y > y) { /* Insert a new node mid-list */ ItNode existing_node = it_node ; it_node = new ItNode( edge0, edge1, x, y, existing_node ); } else { /* Head further down the list */ it_node.next = add_intersection( it_node.next, edge0, edge1, x, y); } } return it_node ; }
private static StNode add_st_edge( StNode st, ItNodeTable it, EdgeNode edge, double dy) { if (st == null) { /* Append edge onto the tail end of the ST */ st = new StNode( edge, null ); } else { double den= (st.xt - st.xb) - (edge.xt - edge.xb); /* If new edge and ST edge don't cross */ if( (edge.xt >= st.xt) || (edge.dx == st.dx) || (Math.Abs(den) <= GPC_EPSILON)) { /* No intersection - insert edge here (before the ST edge) */ StNode existing_node = st; st = new StNode( edge, existing_node ); } else { /* Compute intersection between new edge and ST edge */ double r= (edge.xb - st.xb) / den; double x= st.xb + r * (st.xt - st.xb); double y= r * dy; /* Insert the edge pointers and the intersection point in the IT */ it.top_node = add_intersection(it.top_node, st.edge, edge, x, y); /* Head further into the ST */ st.prev = add_st_edge(st.prev, it, edge, dy); } } return st ; }
// Insert the edge. // public void InsertEdge(int x, int y, bool directed) { // Create new edge (x, y). // var p = new EdgeNode(); p.y = y; p.weight = null; // Insert into adjacency list of vertex x. // p.next = edges[x]; edges[x] = p; // Increment degree of vertex x. // degree[x]++; // If graph is undirected, insert edge (y, x). // if (this.directed == false) { if (isCopy == false) { isCopy = true; this.InsertEdge(y, x, true); isCopy = false; } } else { // If graph is directed and directed is // false, insert edge (y, x). // if (directed == false) { this.InsertEdge(y, x, true); } } }