Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void AddVertex(object vertex)
- {
- List<object> tmp = new List<object>();
- graph.Add(vertex, tmp);
- Console.WriteLine("Do you want to add outcomming vertices? ");
- string answer = Console.ReadLine();
- if (answer == "yes")
- {
- Console.WriteLine("Enter outcomming vertices: ");
- string[] outcomingVetices = Console.ReadLine().Split(' ');
- for (int i = 0; i < outcomingVetices.Length; i++)
- tmp.Add(int.Parse(outcomingVetices[i]));
- }
- Console.WriteLine("Do you want to add incomming vertices? ");
- answer = Console.ReadLine();
- if (answer == "yes")
- {
- Console.WriteLine("Enter outcomming vertices: ");
- string[] outcomingVetices = Console.ReadLine().Split(' ');
- for (int i = 0; i < outcomingVetices.Length; i++)
- {
- object vert = int.Parse(outcomingVetices[i]);
- graph[vert].Add(vertex);
- }
- }
- }
- public void AddEdge(object firstVertex, object secondVertex)
- {
- graph[firstVertex].Add(secondVertex);
- }
- public void RemoveVertex(object vertex)
- {
- graph.Remove(vertex);
- foreach (var item in graph)
- {
- if (item.Value.Contains(vertex))
- item.Value.Remove(vertex);
- }
- }
- public void RemoveEdge(object firstVertex, object secondVertex)
- {
- graph[firstVertex].Remove(secondVertex);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement