diff options
author | Toby Vincent <tobyv13@gmail.com> | 2021-03-26 18:15:57 +0000 |
---|---|---|
committer | Toby Vincent <tobyv13@gmail.com> | 2021-03-26 18:15:57 +0000 |
commit | 1c2b72905bb59c911ddbbb99075eaa19f601decb (patch) | |
tree | 499b2bddcb20fe42f21365a55759cd4d476e69e3 | |
parent | 55516440aa3a41b91963bbf97dfa17cbb1e1dcca (diff) |
added constructors
-rw-r--r-- | Graph.cs | 7 | ||||
-rw-r--r-- | Vertex.cs | 3 |
2 files changed, 10 insertions, 0 deletions
@@ -7,6 +7,13 @@ namespace Graph { public List<Vertex<T>> Vertices { get; set; } = new List<Vertex<T>>(); + public Graph() { } + + public Graph(List<Vertex<T>> vertices) + { + Vertices = vertices; + } + public void AddEdge(Edge<T> edge) { Vertex<T> vertex = Vertices.Find(u => u.Id == edge.U); @@ -12,6 +12,9 @@ namespace Graph public Vertex(int id) : base(id) { } + public Vertex(int id, List<Edge<T>> edges) : this(id) => + Edges = edges; + public override string ToString() => $"{Id} {String.Join(" ", Edges)}"; } } |