summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorToby Vincent <tobyv13@gmail.com>2021-03-26 18:15:57 +0000
committerToby Vincent <tobyv13@gmail.com>2021-03-26 18:15:57 +0000
commit1c2b72905bb59c911ddbbb99075eaa19f601decb (patch)
tree499b2bddcb20fe42f21365a55759cd4d476e69e3
parent55516440aa3a41b91963bbf97dfa17cbb1e1dcca (diff)
added constructors
-rw-r--r--Graph.cs7
-rw-r--r--Vertex.cs3
2 files changed, 10 insertions, 0 deletions
diff --git a/Graph.cs b/Graph.cs
index 59fa004..5841035 100644
--- a/Graph.cs
+++ b/Graph.cs
@@ -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);
diff --git a/Vertex.cs b/Vertex.cs
index 98abb07..31a40b4 100644
--- a/Vertex.cs
+++ b/Vertex.cs
@@ -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)}";
}
}