public void Add_VertexNode_ReturnBool() { adjList.Add("A"); adjList.Add("B"); adjList.Add("C"); adjList.Add("D"); adjList.Add("E"); Assert.AreEqual(true, adjList.Contains(adjList[0])); Assert.AreEqual(true, adjList.Contains(adjList.Find("A"))); }
/// <summary> /// Returns all of the Edges connected to a Vertex as well as the edge's accociated weight /// </summary> /// <param name="parent">The Vertex to return all accociated edges</param> /// <returns>All edges accociated with the parent</returns> public Tuple <Vertex, int>[] GetNeighbors(Vertex parent) { AdjacencyRow row = AdjacencyList.Find(a => a.KeyVertex.Value == parent.Value); Tuple <Vertex, int>[] result = new Tuple <Vertex, int> [row.AdjacencyCount]; int i = 0; foreach (Tuple <Vertex, int> edge in row.Edges) { result[i] = edge; i++; } return(result); }
/// <summary> /// A utility function that checks for an existing Adjacency Row with the Vertex passed /// Or creates one if it doesn't exist /// </summary> /// <param name="vertex">The Vertex to check for or create in the Adjacency List</param> /// <returns>The Row that was found or created with the passed in vertex as its key</returns> private AdjacencyRow FindOrCreateAdjacencyRow(Vertex vertex) { AdjacencyRow RowWithKey = null; foreach (AdjacencyRow row in AdjacencyList) { if (row.KeyVertex.Value == vertex.Value) { RowWithKey = row; } } if (RowWithKey == null) { AddNewAdjacencyRow(vertex); RowWithKey = AdjacencyList.Find(v => v.KeyVertex.Value == vertex.Value); } return(RowWithKey); }
AdjacencyList <string> .Vertex <string> FindConnectedCity(string city) { return(city_list.Find(city)); }