public OrientedGraph <T> DeleteVertex(int vertexIndex) { var result = new OrientedGraph <T>(VerticesCount - 1); for (int p1 = 0, p2 = 0; p1 < VerticesCount; p1++) { if (p1 != vertexIndex) { result.verticesInfo[p2] = verticesInfo[p1].Clone(); for (int q1 = 0, q2 = 0; q1 < VerticesCount; q1++) { if (q1 != vertexIndex) { result.adjacencyMatrix[p2, q2] = adjacencyMatrix[p1, q1]; q2++; } } p2++; } } return(result); }
public OrientedGraph <T> Intersect(OrientedGraph <T> second, Func <T, T, T> addFunc) { int minNodes = Math.Min(VerticesCount, second.VerticesCount); var graph_Intersection = new OrientedGraph <T>(minNodes); for (int p = 0; p < minNodes; p++) { for (int q = 0; q < minNodes; q++) { if (adjacencyMatrix[p, q] && second.adjacencyMatrix[p, q]) { graph_Intersection.adjacencyMatrix[p, q] = true; } } graph_Intersection.verticesInfo[p] = new GraphNode <T>( "node" + p, addFunc == null ? default : addFunc(verticesInfo[p].Value, second.verticesInfo[p].Value) ); } return(graph_Intersection); }