Beispiel #1
0
 public override bool AddEdge(int start, int end, EdgeType val) // adds new edge with data specified
 {
     if (VertexLinkExist(start, end))
     {
         return(false);
     }
     Misc.Edge <EdgeType> edg = new Misc.Edge <EdgeType>();
     edg.StartVertexid = start;
     edg.EndVertexid   = end;
     edg.Value         = val;
     edges.Add(edg);
     data[start].Add(GetVertexById(end));
     if (!IsDirected)
     {
         Misc.Edge <EdgeType> back = new Misc.Edge <EdgeType>();
         back.StartVertexid = end;
         back.EndVertexid   = start;
         back.Value         = val;
         edges.Add(back);
         data[end].Add(GetVertexById(start));
         EdgeCount++;
     }
     EdgeCount++;
     return(true);//operation succeded
 }
Beispiel #2
0
        public List <Misc.Vertex <VertexType> > Vertexes = new List <Misc.Vertex <VertexType> >();// contains vertex objects

        public MatrixBasedGraph(int VertexCount, bool oriented)
        {
            this.VertexCount = VertexCount;
            IsDirected       = oriented;
            Data             = new Misc.Edge <EdgeType> [VertexCount, VertexCount];
            for (int i = 0; i < VertexCount; i++)
            {
                Misc.Vertex <VertexType> temp = new Misc.Vertex <VertexType>();
                temp.id = i;
                Vertexes.Add(temp);
            }
        }
Beispiel #3
0
 public override bool AddEdge(int start, int end, EdgeType val)// adds new edge with data specified
 {
     if (start == end)
     {
         return(false);
     }
     if (EdgeExists(start, end))
     {
         return(false);
     }
     Misc.Edge <EdgeType> edg = new Misc.Edge <EdgeType>();
     edg.StartVertexid = start;
     edg.EndVertexid   = end;
     edg.Value         = val;
     Data[start, end]  = edg;
     if (!IsDirected)
     {
         Data[end, start] = edg;
     }
     EdgeCount++;
     return(true);//operation succeded
 }