public bool AddVertex(char name) { int exists = Names.FindIndex(e => e == name); if (exists == -1) { int n = this.AdjacencyMatrix.GetLength(0); int[,] NewAdjacencyMatrix = new int[n + 1, n + 1]; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { NewAdjacencyMatrix[i, j] = AdjacencyMatrix[i, j]; } } AdjacencyMatrix = NewAdjacencyMatrix; Names.Add(name); Degrees.Add(0); AdjacencyList.Add(new List <int>()); return(true); } else { return(false); } }
private void InitializeInDegrees() { foreach (TVertex vertex in VisitedGraph.Vertices) { Degrees.Add(vertex, VisitedGraph.AdjacentDegree(vertex)); _heap.Enqueue(vertex); } }
private void InitializeInDegrees() { if (!AllowCyclicGraph && VisitedGraph.Edges.Any(edge => edge.IsSelfEdge())) { throw new NonAcyclicGraphException(); } foreach (TVertex vertex in VisitedGraph.Vertices) { Degrees.Add(vertex, VisitedGraph.AdjacentDegree(vertex)); _heap.Enqueue(vertex); } }