Exemple #1
0
        public GraphEdge addEdge(GraphNode head, GraphNode tail, object data = null)
        {
            var edge = new GraphEdge(head, tail, data);

            head.addEdgeOut(edge);
            tail.addEdgeIn(edge);

            this.edges.Add(edge);
            return(edge);
        }
Exemple #2
0
        public void removeEdge(GraphEdge edge)
        {
            var head = edge.getHead();

            head.removeEdgeOut(edge);

            var tail = edge.getTail();

            tail.removeEdgeIn(edge);

            this.edges.Remove(edge);
        }
        public int[,] GetEdgeIndex()
        {
            List <GraphEdge> edges = this.g.getEdges();

            int[,] edgeIndex = new int[edges.Count, 2];
            for (int i = 0; i < edges.Count; i++)
            {
                GraphEdge e             = edges[i];
                int       headNodeIndex = GetNodeIndex(e.getHead());
                int       tailNodeIndex = GetNodeIndex(e.getTail());
                edgeIndex[i, 0] = headNodeIndex;
                edgeIndex[i, 1] = tailNodeIndex;
            }

            return(edgeIndex);
        }
        public List <float[]> GetEdges(List <float[]> nodePositions)
        {
            List <float[]> lines   = new List <float[]>();
            int            numDims = nodePositions[0].Length * 2;

            List <GraphEdge> edges = this.g.getEdges();

            int[,] edgeIndex = new int[edges.Count, 2];
            for (int i = 0; i < edges.Count; i++)
            {
                GraphEdge e = edges[i];

                float[] headPos = this.g.GetNodePosition(e.getHead());
                float[] tailPos = this.g.GetNodePosition(e.getTail());

                float[] newLine = new float[numDims];
                headPos.CopyTo(newLine, 0);
                tailPos.CopyTo(newLine, tailPos.Length);

                lines.Add(newLine);
            }
            return(lines);
        }
Exemple #5
0
 public void removeEdgeOut(GraphEdge edge)
 {
     eout.Remove(edge);
 }
Exemple #6
0
 public void removeEdgeIn(GraphEdge edge)
 {
     ein.Remove(edge);
 }
Exemple #7
0
 public void addEdgeOut(GraphEdge edge)
 {
     eout.Add(edge);
 }
Exemple #8
0
 public void addEdgeIn(GraphEdge edge)
 {
     ein.Add(edge);
 }