Example #1
0
 public void AddVertex(Vertex aVertex)
 {
     if (!mVertexes.Contains(aVertex))
         mVertexes.Add(aVertex);             //vložíme vrchol
     else
         throw new GraphException("vrchol existuje", GraphExampleMessageType.EDGE);
 }
Example #2
0
 public void RemoveVertex(Vertex aVertex)
 {
     if (aVertex != null && mVertexes.Contains(aVertex))
     {
         Edge[] spojene = GetEdgesWithVertex(aVertex); //hrany ktere jsou s vrcholem spojene
         mVertexes.Remove(aVertex);  //odstanime vrchol
         foreach (Edge h in spojene)
             RemoveEdge(h);
     }
     else
         throw new GraphException("vrchol v grafu neexistuje", GraphExampleMessageType.VERTEX);
 }
Example #3
0
        private Edge[] GetEdgesWithVertex(Vertex aVertex)
        {
            //už víme, že vrchol v grafu existuje a je not null
            List<Edge> list = new List<Edge>();

            foreach (Edge h in mEdges)
            {
                if (h.Vertex1 == aVertex || h.Vertex2 == aVertex)
                    list.Add(h);
            }

            return list.ToArray();
        }
Example #4
0
 public Vertex(Vertex aVertex)
 {
     this.Value = aVertex.Value;
 }