private void RebuildVerticesFromPaths() { ve.Vertices.Clear(); ve.VertexMap.Clear(); foreach (Path p in paths) { int v1Key = ve.GetVertexKey(p.V1); if (!ve.VertexMap.ContainsKey(v1Key)) { ve.Vertices.Add(p.V1); ve.VertexMap.Add(v1Key, p.V1); } int v2Key = ve.GetVertexKey(p.V2); if (!ve.VertexMap.ContainsKey(v2Key)) { ve.Vertices.Add(p.V2); ve.VertexMap.Add(v2Key, p.V2); } } }
private void InsertVertexPath(Vertex vertex, Path path) { int key = VertexExtractor.GetVertexKey(vertex); List <Path> paths; if (vertexPaths.ContainsKey(key)) { paths = vertexPaths[key]; } else { paths = new List <Path>(); vertexPaths.Add(key, paths); } paths.Add(path); }
public List <Path> FindLoosePaths() { List <Path> loosePaths = new List <Path>(); foreach (Path p in paths) { int v1Key = VertexExtractor.GetVertexKey(p.V1); int v2Key = VertexExtractor.GetVertexKey(p.V2); int v1PathCount = vertexPaths[v1Key].Count; int v2PathCount = vertexPaths[v2Key].Count; if (v1PathCount == 1 || v2PathCount == 1) { loosePaths.Add(p); } } return(loosePaths); }
public void RemovePath(Path path) { long key = GetPathKey(path); paths.Remove(path); pathMap.Remove(key); int v1Key = VertexExtractor.GetVertexKey(path.V1); int v2Key = VertexExtractor.GetVertexKey(path.V2); vertexPaths[v1Key].Remove(path); if (vertexPaths[v1Key].Count == 0) { ve.Vertices.Remove(path.V1); ve.VertexMap.Remove(v1Key); vertexPaths.Remove(v1Key); } vertexPaths[v2Key].Remove(path); if (vertexPaths[v2Key].Count == 0) { ve.Vertices.Remove(path.V2); ve.VertexMap.Remove(v2Key); vertexPaths.Remove(v2Key); } }