using System.Collections.Generic;
public static void Main()
Console.WriteLine("Graph:");
g.nodes = new List<Node>();
g.nodes.Add(new Node("A"));
g.nodes.Add(new Node("B"));
g.nodes.Add(new Node("C"));
g.nodes.Add(new Node("D"));
g.edges = new List<Edge>();
g.edges.Add(new Edge("ab", "A", "B"));
g.edges.Add(new Edge("bc", "B", "C"));
Graph.RemoveGraphEntities(g, new List<string>(new string[]{"C", "D"}), new List<string>(new string[]{}));
public Edge(string id, string startNodeId, string endNodeId)
this.startNodeId = startNodeId;
this.endNodeId = endNodeId;
public string startNodeId;
Console.WriteLine(String.Format(" Edge {0} between node {1} and {2}", this.id, this.startNodeId, this.endNodeId));
Console.WriteLine(String.Format(" Node {0}", this.id));
foreach (Node n in this.nodes)
foreach (Edge e in this.edges)
public static void RemoveGraphEntities(Graph graph, List<string> nodeIdsToRemove, List<string> edgeIdsToRemove)
Queue<Node> nodeQueue = new Queue<Node>();
foreach (string nodeId in nodeIdsToRemove)
foreach (Node node in graph.nodes)
graph.nodes.Remove(node);
graph.edges.RemoveAll(k => k.startNodeId == nodeId);
graph.edges.RemoveAll(k => k.endNodeId == nodeId);
foreach (string edgeId in edgeIdsToRemove)
foreach (Edge edge in graph.edges)
graph.edges.RemoveAll(k => k.id == edgeId);