From 1c2b72905bb59c911ddbbb99075eaa19f601decb Mon Sep 17 00:00:00 2001 From: Toby Vincent Date: Fri, 26 Mar 2021 18:15:57 +0000 Subject: added constructors --- Graph.cs | 7 +++++++ Vertex.cs | 3 +++ 2 files changed, 10 insertions(+) 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> Vertices { get; set; } = new List>(); + public Graph() { } + + public Graph(List> vertices) + { + Vertices = vertices; + } + public void AddEdge(Edge edge) { Vertex 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> edges) : this(id) => + Edges = edges; + public override string ToString() => $"{Id} {String.Join(" ", Edges)}"; } } -- cgit v1.2.3-70-g09d2