protected virtual void RemoveEdgeControl(HyperEdge hyperEdge) { var hec = HyperEdgeControls[hyperEdge]; HyperEdgeControls.Remove(hyperEdge); InternalChildren.Remove(hec); }
protected virtual void CreateHyperEdgeControl(HyperEdge hyperEdge) { var hyperEdgeControl = new HyperEdgeControl { HyperEdge = hyperEdge, DataContext = hyperEdge }; if (HyperEdgeControls.TryAdd(hyperEdge, hyperEdgeControl) is false) { HyperEdgeControls[hyperEdge] = hyperEdgeControl; } // var findVertexList = new List<VertexControl>(); // foreach (var v in hyperEdge.Vertices) // { // if (VertexControls.TryGetValue(v, out var vertexControl) is true) // { // if (vertexControl != null) // findVertexList.Add(vertexControl); // } // } // // hyperEdgeControl.Vertices = findVertexList.ToArray(); hyperEdgeControl.Vertices = hyperEdge.Vertices.Select(v => VertexControls[v]).ToArray(); foreach (var vertexControl in hyperEdgeControl.Vertices) { vertexControl.HyperEdges.Add(hyperEdgeControl); } InternalChildren.Add(hyperEdgeControl); }
public void HyperGraph_GetAdjacentEdges_has_to_work() { HyperGraph hyperGraph = new HyperGraph(); Vertex v1 = hyperGraph.AddVertex("00"); Vertex v2 = hyperGraph.AddVertex("01"); Vertex v3 = hyperGraph.AddVertex("10"); HyperEdge h1 = hyperGraph.AddEdge("00", "00", "00"); HyperEdge h2 = hyperGraph.AddEdge("00", "01", "10"); HyperEdge h3 = hyperGraph.AddEdge("00", "00"); HyperEdge h4 = hyperGraph.AddEdge("01", "10"); List <HyperEdge> neighbors = hyperGraph.GetAdjacentEdges(v1).ToList(); Assert.AreEqual(3, neighbors.Count); Assert.IsTrue(neighbors.Contains(h1)); Assert.IsTrue(neighbors.Contains(h2)); Assert.IsTrue(neighbors.Contains(h3)); neighbors = hyperGraph.GetAdjacentEdges(v2).ToList(); Assert.AreEqual(2, neighbors.Count); Assert.IsTrue(neighbors.Contains(h2)); Assert.IsTrue(neighbors.Contains(h4)); neighbors = hyperGraph.GetAdjacentEdges(v2, 2).ToList(); Assert.AreEqual(1, neighbors.Count); Assert.IsTrue(neighbors.Contains(h4)); neighbors = hyperGraph.GetAdjacentEdges(v2, 3).ToList(); Assert.AreEqual(1, neighbors.Count); Assert.IsTrue(neighbors.Contains(h2)); }
public IEdge GetElementById(Guid id, string table) { if (!cache.ContainsKey(id)) { string sql = String.Format(rawSqlProvider.SelectById, table, id); using (DbCommand command = (ConcreteCommand)Activator.CreateInstance(typeof(ConcreteCommand), new object[] { sql, connection })) { using (DbDataReader reader = command.ExecuteReader()) { if (reader.Read()) { GraphObjectTypeInfo ti = types[reader["type_id"].ToString()]; Guid source = Guid.Parse(reader["source"].ToString()); Guid target = Guid.Parse(reader["target"].ToString()); IEdge edge = new HyperEdge(id, ti, provider, new List <Guid>() { source, target }); cache.Add(id, edge); } else { throw new Exception("Missing edge data."); } } } } return(cache[id]); }
/// <summary> /// /// </summary> /// <param name="typeTable"></param> /// <param name="nodeTable">Dictionnaire qui associe une référence interne à une instance de noeud.</param> void ResolveInternalEdges(GraphObjectTypeInfo[] typeTable, IDictionary <int, IVertex> nodeTable) { List <EdgeInfo> processed = new List <EdgeInfo>(); foreach (EdgeInfo edgeInfo in edgesDeclarations.Where(i => i.ContainsExternal == false)) { if (edgeInfo.Oriented) { // TODO throw new NotImplementedException(); } else { // normalement tous les id sont locaux et ne concernent que des noeuds car les relations ne peuvent être cible d'une relation que par leur id public IEnumerable <IVertex> vertices = edgeInfo.LinkedObjects.Select(i => nodeTable[i.IntValue]); IEdge edgeInstance = new HyperEdge(edgeInfo.PublicId, typeTable[edgeInfo.Type], vertices.ToArray()); edgeInstances.Add(edgeInfo.PublicId, edgeInstance); } processed.Add(edgeInfo); } foreach (EdgeInfo info in processed) { edgesDeclarations.Remove(info); } }
public void GetSuccessorsTests_1() { // v1 -> v2 -> v3 IVertex first = VertexExtensions.CreateTextVertex(vertexType, "v1"); IVertex second = VertexExtensions.CreateTextVertex(vertexType, "v2"); IVertex third = VertexExtensions.CreateTextVertex(vertexType, "v3"); IEdge first_edge = new HyperEdge(edgeType, first, second); IEdge second_edge = new HyperEdge(edgeType, second, third); // à partir de v1 on doit obtenir seulement v2 var neighboors = first.Successors(edgeType); Assert.IsNotNull(neighboors); Assert.AreEqual <int>(1, neighboors.Count); Assert.AreSame(second, neighboors[0]); // à partir de v2 on doit obtenir seulement v3 neighboors.Clear(); neighboors = second.Successors(edgeType); Assert.IsNotNull(neighboors); Assert.AreEqual <int>(1, neighboors.Count); Assert.AreSame(third, neighboors[0]); // à partir de v3 on doit ne doit rien obtenir neighboors.Clear(); neighboors = third.Successors(edgeType); Assert.IsNotNull(neighboors); Assert.AreEqual <int>(0, neighboors.Count); }
public void GetNeighborVertices_has_to_work() { Vertex v1 = new Vertex("00"); Vertex v2 = new Vertex("00"); Vertex v3 = new Vertex("00"); HyperEdge h1 = new HyperEdge(v1, v2, v3); Vertex v11 = h1.GetEdgeVertexInstance(v1); Vertex v21 = h1.GetEdgeVertexInstance(v2); Vertex v31 = h1.GetEdgeVertexInstance(v3); Vertex v41 = h1.GetEdgeVertexInstance(v3); Assert.AreNotEqual(v11, v21); Assert.AreNotEqual(v11, v31); Assert.AreNotEqual(v21, v31); Assert.AreEqual(v11, v41); IEnumerable <Vertex> neigbors = h1.GetNeighborVertices(v11); Assert.AreEqual(2, neigbors.Count()); Assert.AreEqual(1, neigbors.Where(v => v.EqualsOnVertexBasis(v2)).Count()); Assert.AreEqual(1, neigbors.Where(v => v.EqualsOnVertexBasis(v3)).Count()); Assert.AreEqual(1, neigbors.Where(v => v.EqualsOnEdgeBasis(v21)).Count()); Assert.AreEqual(1, neigbors.Where(v => v.EqualsOnEdgeBasis(v31)).Count()); }
public void Hexagon_GetIncomingFace_has_to_work() { HyperEdge edge = new HyperEdge("00", "00", "00", TileOrientation.Straight); Hexagon hexagon = new Hexagon(edge, TileFace.Right, new HyperEdge("00", "00")); Assert.AreEqual(TileFace.Left, hexagon.GetIncomingFace(0, TileOrientation.Straight)); Assert.AreEqual(TileFace.Left, hexagon.GetIncomingFace(1, TileOrientation.TiltLeft)); Assert.AreEqual(TileFace.Left, hexagon.GetIncomingFace(2, TileOrientation.DoubleTiltLeft)); Assert.AreEqual(TileFace.Left, hexagon.GetIncomingFace(3, TileOrientation.Flipped)); Assert.AreEqual(TileFace.Left, hexagon.GetIncomingFace(4, TileOrientation.DoubleTiltRight)); Assert.AreEqual(TileFace.Left, hexagon.GetIncomingFace(5, TileOrientation.TiltRight)); Assert.AreEqual(TileFace.Right, hexagon.GetIncomingFace(0, TileOrientation.DoubleTiltLeft)); Assert.AreEqual(TileFace.Right, hexagon.GetIncomingFace(1, TileOrientation.Flipped)); Assert.AreEqual(TileFace.Right, hexagon.GetIncomingFace(2, TileOrientation.DoubleTiltRight)); Assert.AreEqual(TileFace.Right, hexagon.GetIncomingFace(3, TileOrientation.TiltRight)); Assert.AreEqual(TileFace.Right, hexagon.GetIncomingFace(4, TileOrientation.Straight)); Assert.AreEqual(TileFace.Right, hexagon.GetIncomingFace(5, TileOrientation.TiltLeft)); Assert.AreEqual(TileFace.Bottom, hexagon.GetIncomingFace(0, TileOrientation.DoubleTiltRight)); Assert.AreEqual(TileFace.Bottom, hexagon.GetIncomingFace(1, TileOrientation.TiltRight)); Assert.AreEqual(TileFace.Bottom, hexagon.GetIncomingFace(2, TileOrientation.Straight)); Assert.AreEqual(TileFace.Bottom, hexagon.GetIncomingFace(3, TileOrientation.TiltLeft)); Assert.AreEqual(TileFace.Bottom, hexagon.GetIncomingFace(4, TileOrientation.DoubleTiltLeft)); Assert.AreEqual(TileFace.Bottom, hexagon.GetIncomingFace(5, TileOrientation.Flipped)); }
public void GetPredecessorsTests_1() { // v1 -> v2 -> v3 IVertex first = VertexExtensions.CreateTextVertex(vertexType, "v1"); IVertex second = VertexExtensions.CreateTextVertex(vertexType, "v2"); IVertex third = VertexExtensions.CreateTextVertex(vertexType, "v3"); IEdge first_edge = new HyperEdge(edgeType, first, second); IEdge second_edge = new HyperEdge(edgeType, second, third); var neighboors = first.Predecessors(edgeType); Assert.IsNotNull(neighboors); Assert.AreEqual <int>(0, neighboors.Count); neighboors.Clear(); neighboors = second.Predecessors(edgeType); Assert.IsNotNull(neighboors); Assert.AreEqual <int>(1, neighboors.Count); Assert.AreSame(first, neighboors[0]); neighboors.Clear(); neighboors = third.Predecessors(edgeType); Assert.IsNotNull(neighboors); Assert.AreEqual <int>(1, neighboors.Count); Assert.AreSame(second, neighboors[0]); }
public void Contains_Methods_has_to_work() { Vertex vertex1 = new Vertex("00"); HyperEdge test2 = new HyperEdge(vertex1, vertex1, vertex1); Assert.IsTrue(test2.ContainsOnVertexBasis(vertex1)); Assert.IsFalse(test2.ContainsOnEdgeBasis(vertex1)); }
protected HyperEdgeControl GetOrCreateEdgeControl(HyperEdge edge) { if (!HyperEdgeControls.ContainsKey(edge)) { CreateHyperEdgeControl(edge); } return(HyperEdgeControls[edge]); }
public void Hexagon_DetermineHexagonPosition_has_to_work() { HyperEdge edge = new HyperEdge("00", "00", "00", TileOrientation.Straight); HyperEdge connector = new HyperEdge("00", "00"); Hexagon hexagon = new Hexagon(edge, TileFace.Right, connector); Assert.AreEqual(0, hexagon.Pointer); hexagon = new Hexagon(edge, TileFace.Left, connector); Assert.AreEqual(2, hexagon.Pointer); hexagon = new Hexagon(edge, TileFace.Bottom, connector); Assert.AreEqual(4, hexagon.Pointer); edge = new HyperEdge("00", "00", "00", TileOrientation.DoubleTiltRight); hexagon = new Hexagon(edge, TileFace.Left, connector); Assert.AreEqual(0, hexagon.Pointer); hexagon = new Hexagon(edge, TileFace.Bottom, connector); Assert.AreEqual(2, hexagon.Pointer); hexagon = new Hexagon(edge, TileFace.Right, connector); Assert.AreEqual(4, hexagon.Pointer); edge = new HyperEdge("00", "00", "00", TileOrientation.DoubleTiltLeft); hexagon = new Hexagon(edge, TileFace.Bottom, connector); Assert.AreEqual(0, hexagon.Pointer); hexagon = new Hexagon(edge, TileFace.Right, connector); Assert.AreEqual(2, hexagon.Pointer); hexagon = new Hexagon(edge, TileFace.Left, connector); Assert.AreEqual(4, hexagon.Pointer); edge = new HyperEdge("00", "00", "00", TileOrientation.TiltLeft); hexagon = new Hexagon(edge, TileFace.Right, connector); Assert.AreEqual(1, hexagon.Pointer); hexagon = new Hexagon(edge, TileFace.Left, connector); Assert.AreEqual(3, hexagon.Pointer); hexagon = new Hexagon(edge, TileFace.Bottom, connector); Assert.AreEqual(5, hexagon.Pointer); edge = new HyperEdge("00", "00", "00", TileOrientation.TiltRight); hexagon = new Hexagon(edge, TileFace.Left, connector); Assert.AreEqual(1, hexagon.Pointer); hexagon = new Hexagon(edge, TileFace.Bottom, connector); Assert.AreEqual(3, hexagon.Pointer); hexagon = new Hexagon(edge, TileFace.Right, connector); Assert.AreEqual(5, hexagon.Pointer); edge = new HyperEdge("00", "00", "00", TileOrientation.Flipped); hexagon = new Hexagon(edge, TileFace.Bottom, connector); Assert.AreEqual(1, hexagon.Pointer); hexagon = new Hexagon(edge, TileFace.Right, connector); Assert.AreEqual(3, hexagon.Pointer); hexagon = new Hexagon(edge, TileFace.Left, connector); Assert.AreEqual(5, hexagon.Pointer); }
public void Hexagon_CheckIfLastConnectorConnectsInAndOutgoing_has_to_work() { HyperEdge edge = new HyperEdge("00", "00", "00", TileOrientation.Straight); Hexagon hexagon = new Hexagon(edge, TileFace.Right, new HyperEdge("00", "00")); HyperEdge connector1 = new HyperEdge("00", "00"); HyperEdge connector2 = new HyperEdge("01", "10"); Assert.IsTrue(hexagon.CheckIfLastConnectorConnectsInAndOutgoing(new Vertex("00"), new Vertex("00"), connector1)); Assert.IsTrue(hexagon.CheckIfLastConnectorConnectsInAndOutgoing(new Vertex("01"), new Vertex("10"), connector2)); Assert.IsTrue(hexagon.CheckIfLastConnectorConnectsInAndOutgoing(new Vertex("10"), new Vertex("01"), connector2)); Assert.IsFalse(hexagon.CheckIfLastConnectorConnectsInAndOutgoing(new Vertex("10"), new Vertex("10"), connector2)); Assert.IsFalse(hexagon.CheckIfLastConnectorConnectsInAndOutgoing(new Vertex("01"), new Vertex("01"), connector2)); }
public void VertexExtensionsOne() { IVertex origin = VertexExtensions.CreateTextVertex(vertexType, "v1"); IVertex target = VertexExtensions.CreateTextVertex(vertexType, "v2"); IEdge edge = new HyperEdge(edgeType, origin, target); var neighboors = origin.Successors(edgeType); Assert.IsNotNull(neighboors); Assert.AreEqual <int>(1, neighboors.Count); Assert.AreSame(target, neighboors[0]); neighboors.Clear(); neighboors = target.Successors(edgeType); Assert.IsNotNull(neighboors); Assert.AreEqual <int>(0, neighboors.Count); }
public void Equals_hast_to_work() { List <HyperEdge> triominioEdges = GraphGenerator.GetAllTriominoEdges().ToList(); for (int i = 0; i < triominioEdges.Count; i++) { for (int j = i + 1; j < triominioEdges.Count; j++) { Assert.AreNotEqual(triominioEdges[i], triominioEdges[j]); Assert.IsFalse(triominioEdges[i].EqualsOnValueBasis(triominioEdges[j])); Assert.IsFalse(triominioEdges[i].EqualsOnVertexBasis(triominioEdges[j])); } Assert.AreEqual(triominioEdges[i], triominioEdges[i]); Assert.IsTrue(triominioEdges[i].EqualsOnValueBasis(triominioEdges[i])); } Vertex vertex1 = new Vertex("00"); Vertex vertex2 = Vertex.CreateFromVertex(vertex1); Vertex vertex3 = Vertex.CreateFromVertex(vertex1); Vertex vertex4 = Vertex.CreateFromVertex(vertex1); HyperEdge test1 = new HyperEdge(vertex1, vertex2, vertex3); HyperEdge test2 = new HyperEdge(vertex1, vertex2, vertex3); HyperEdge test3 = new HyperEdge(vertex1, vertex2, vertex4); Assert.AreEqual(test1, test1); Assert.AreNotEqual(test1, test2); Assert.AreNotEqual(test1, test3); Assert.AreNotEqual(test2, test3); Assert.IsTrue(test1.EqualsOnVertexBasis(test2)); Assert.IsTrue(test1.EqualsOnVertexBasis(test3)); Assert.IsTrue(test2.EqualsOnVertexBasis(test3)); HyperEdge h1 = new HyperEdge("11", "11", "11"); HyperEdge h2 = new HyperEdge("01", "11", "10"); Assert.IsFalse(h1.EqualsOnValueBasis(h2)); HyperEdge h3 = new HyperEdge("12", "23", "31"); HyperEdge h4 = new HyperEdge("12", "23", "31"); Assert.IsTrue(h3.EqualsOnValueBasis(h4)); }
public static async Task <HyperGraph> CollectionToHyperGraphTaskAsync( IMongoCollection <BsonDocument> bsonDocCollection) { var hyperGraph = new HyperGraph(bsonDocCollection.CollectionNamespace.CollectionName); await foreach (var keys in ParseCollectionAsync(bsonDocCollection.AsQueryable())) { var edge = new HyperEdge { Weight = 1 }; foreach (var key in keys) { var vertex = hyperGraph.Vertices.FirstOrDefault(v => v.Data?.Equals(key) ?? false); if (vertex is null) { vertex = new Vertex(key); hyperGraph.Vertices.Add(vertex); } vertex.HyperEdges.Add(edge); edge.Vertices.Add(vertex); } var existHyperEdge = hyperGraph.HyperEdges.FirstOrDefault(he => he.Vertices.SetEquals(edge.Vertices)); if (existHyperEdge is null) { hyperGraph.HyperEdges.Add(edge); } else { foreach (var vertex in edge.Vertices) { vertex.HyperEdges.RemoveWhere(e => e.Id == edge.Id); vertex.HyperEdges.Add(existHyperEdge); } existHyperEdge.Weight++; } } return(hyperGraph); }
void ResolveExternalEdges() { foreach (EdgeInfo edgeInfo in edgesDeclarations) { if (edgeInfo.Oriented) { // TODO throw new NotImplementedException(); } else { // on cherche les objets du graph dont les id correspondent aux cibles du lien // ATTENTION si la cible est un lien, elle n'est pas forcément instanciée IEnumerable <IGraphObject> graphObjects = edgeInfo.LinkedObjects.Select(ei => GetObjectById(ei.GuidValue)); IEdge edgeInstance = new HyperEdge(edgeInfo.PublicId, edgeInfo.GuidType, graphObjects.ToArray()); edgeInstances.Add(edgeInfo.PublicId, edgeInstance); } } }
public void HyperGraph_AddEdge_has_to_work() { HyperGraph hyperGraph = new HyperGraph(); Assert.ThrowsException <ArgumentException>(() => { hyperGraph.AddEdge("00", "00", "00"); }, "This graph does not conatin a vertex with value '00'."); Vertex v1 = hyperGraph.AddVertex("00"); HyperEdge h1 = hyperGraph.AddEdge("00", "00", "00"); Assert.AreEqual(3, h1.VertexCount()); Assert.IsTrue(h1.ContainsOnVertexBasis(v1)); HyperEdge h2 = new HyperEdge("00", "01", "10"); Assert.ThrowsException <ArgumentException>(() => { hyperGraph.AddEdge(new Vertex("00"), new Vertex("01"), new Vertex("10")); }, $"This graph does not conatin a vertex with value '01'"); Vertex v2 = hyperGraph.AddVertex("11"); Vertex v3 = hyperGraph.AddVertex("01"); Vertex v4 = hyperGraph.AddVertex("10"); Assert.ThrowsException <ArgumentException>(() => hyperGraph.AddEdge(v2, v2, v2), "Vertices must not be equal."); HyperEdge h3 = hyperGraph.AddEdge(v1, v3, v4); Assert.IsTrue(h3.ContainsOnVertexBasis(v1)); Assert.IsTrue(h3.ContainsOnVertexBasis(v3)); Assert.IsTrue(h3.ContainsOnVertexBasis(v4)); Assert.IsFalse(h3.ContainsOnEdgeBasis(v1)); Assert.IsFalse(h3.ContainsOnEdgeBasis(v3)); Assert.IsFalse(h3.ContainsOnEdgeBasis(v4)); HyperEdge h4 = new HyperEdge(new Vertex("00"), new Vertex("01"), new Vertex("10")); Assert.IsTrue(hyperGraph.HasEdge(h4)); Assert.ThrowsException <ArgumentException>(() => { hyperGraph.AddEdge(new Vertex("00"), new Vertex("01"), new Vertex("10")); }, $"This Graph has already an edge '-00-01-10->'."); Assert.ThrowsException <ArgumentException>(() => { hyperGraph.AddEdge("00", "01", "10"); }, $"This Graph has already an edge '-00-01-10->'."); }
public void Hexagon_TryAddToHexagon_has_to_work() { // Positive test HyperEdge edge0 = new HyperEdge("00", "00", "00", TileOrientation.Straight); HyperEdge edge1 = new HyperEdge("00", "02", "20", TileOrientation.Flipped); HyperEdge edge2 = new HyperEdge("02", "22", "20", TileOrientation.DoubleTiltLeft); HyperEdge edge3 = new HyperEdge("01", "12", "20", TileOrientation.Flipped); HyperEdge edge4 = new HyperEdge("01", "11", "10", TileOrientation.DoubleTiltRight); HyperEdge edge5 = new HyperEdge("00", "01", "10", TileOrientation.TiltRight); HyperEdge connector0u5 = new HyperEdge("00", "00"); HyperEdge connector1u2 = new HyperEdge("02", "20"); HyperEdge connector3u4 = new HyperEdge("01", "10"); Hexagon hexagon = new Hexagon(edge0, TileFace.Right, connector0u5); Assert.IsTrue(hexagon.TryAddToHexagon(edge1, connector1u2)); Assert.IsFalse(hexagon.IsComplete); Assert.IsTrue(hexagon.TryAddToHexagon(edge2, connector1u2)); Assert.IsFalse(hexagon.IsComplete); Assert.IsTrue(hexagon.TryAddToHexagon(edge3, connector3u4)); Assert.IsFalse(hexagon.IsComplete); Assert.IsTrue(hexagon.TryAddToHexagon(edge4, connector3u4)); Assert.IsFalse(hexagon.IsComplete); Assert.IsTrue(hexagon.TryAddToHexagon(edge5, connector0u5)); Assert.IsTrue(hexagon.IsComplete); hexagon = new Hexagon(edge1, TileFace.Bottom, connector1u2); Assert.IsFalse(hexagon.IsComplete); Assert.IsTrue(hexagon.TryAddToHexagon(edge2, connector1u2)); Assert.IsFalse(hexagon.IsComplete); Assert.IsTrue(hexagon.TryAddToHexagon(edge3, connector3u4)); Assert.IsFalse(hexagon.IsComplete); Assert.IsTrue(hexagon.TryAddToHexagon(edge4, connector3u4)); Assert.IsFalse(hexagon.IsComplete); Assert.IsTrue(hexagon.TryAddToHexagon(edge5, connector0u5)); Assert.IsFalse(hexagon.IsComplete); Assert.IsTrue(hexagon.TryAddToHexagon(edge0, connector0u5)); Assert.IsTrue(hexagon.IsComplete); hexagon = new Hexagon(edge2, TileFace.Right, connector1u2); Assert.IsFalse(hexagon.IsComplete); Assert.IsTrue(hexagon.TryAddToHexagon(edge3, connector3u4)); Assert.IsFalse(hexagon.IsComplete); Assert.IsTrue(hexagon.TryAddToHexagon(edge4, connector3u4)); Assert.IsFalse(hexagon.IsComplete); Assert.IsTrue(hexagon.TryAddToHexagon(edge5, connector0u5)); Assert.IsFalse(hexagon.IsComplete); Assert.IsTrue(hexagon.TryAddToHexagon(edge0, connector0u5)); Assert.IsFalse(hexagon.IsComplete); Assert.IsTrue(hexagon.TryAddToHexagon(edge1, connector1u2)); Assert.IsTrue(hexagon.IsComplete); hexagon = new Hexagon(edge3, TileFace.Right, connector3u4); Assert.IsFalse(hexagon.IsComplete); Assert.IsTrue(hexagon.TryAddToHexagon(edge4, connector3u4)); Assert.IsFalse(hexagon.IsComplete); Assert.IsTrue(hexagon.TryAddToHexagon(edge5, connector0u5)); Assert.IsFalse(hexagon.IsComplete); Assert.IsTrue(hexagon.TryAddToHexagon(edge0, connector0u5)); Assert.IsFalse(hexagon.IsComplete); Assert.IsTrue(hexagon.TryAddToHexagon(edge1, connector1u2)); Assert.IsFalse(hexagon.IsComplete); Assert.IsTrue(hexagon.TryAddToHexagon(edge2, connector1u2)); Assert.IsTrue(hexagon.IsComplete); hexagon = new Hexagon(edge4, TileFace.Right, connector3u4); Assert.IsFalse(hexagon.IsComplete); Assert.IsTrue(hexagon.TryAddToHexagon(edge5, connector0u5)); Assert.IsFalse(hexagon.IsComplete); Assert.IsTrue(hexagon.TryAddToHexagon(edge0, connector0u5)); Assert.IsFalse(hexagon.IsComplete); Assert.IsTrue(hexagon.TryAddToHexagon(edge1, connector1u2)); Assert.IsFalse(hexagon.IsComplete); Assert.IsTrue(hexagon.TryAddToHexagon(edge2, connector1u2)); Assert.IsFalse(hexagon.IsComplete); Assert.IsTrue(hexagon.TryAddToHexagon(edge3, connector3u4)); Assert.IsTrue(hexagon.IsComplete); hexagon = new Hexagon(edge5, TileFace.Right, connector0u5); Assert.IsFalse(hexagon.IsComplete); Assert.IsTrue(hexagon.TryAddToHexagon(edge0, connector0u5)); Assert.IsFalse(hexagon.IsComplete); Assert.IsTrue(hexagon.TryAddToHexagon(edge1, connector1u2)); Assert.IsFalse(hexagon.IsComplete); Assert.IsTrue(hexagon.TryAddToHexagon(edge2, connector1u2)); Assert.IsFalse(hexagon.IsComplete); Assert.IsTrue(hexagon.TryAddToHexagon(edge3, connector3u4)); Assert.IsFalse(hexagon.IsComplete); Assert.IsTrue(hexagon.TryAddToHexagon(edge4, connector3u4)); Assert.IsTrue(hexagon.IsComplete); // Negativ tests hexagon = new Hexagon(edge0, TileFace.Right, connector0u5); edge1.Orientation = TileOrientation.Straight; Assert.IsFalse(hexagon.TryAddToHexagon(edge1, connector1u2)); Assert.IsFalse(hexagon.IsComplete); edge1.Orientation = TileOrientation.TiltLeft; Assert.IsFalse(hexagon.TryAddToHexagon(edge1, connector1u2)); Assert.IsFalse(hexagon.IsComplete); edge1.Orientation = TileOrientation.TiltRight; Assert.IsFalse(hexagon.TryAddToHexagon(edge1, connector1u2)); Assert.IsFalse(hexagon.IsComplete); edge1.Orientation = TileOrientation.DoubleTiltLeft; Assert.IsFalse(hexagon.TryAddToHexagon(edge1, connector1u2)); Assert.IsFalse(hexagon.IsComplete); edge1.Orientation = TileOrientation.DoubleTiltRight; Assert.IsFalse(hexagon.TryAddToHexagon(edge1, connector1u2)); Assert.IsFalse(hexagon.IsComplete); edge1.Orientation = TileOrientation.Flipped; Assert.IsFalse(hexagon.TryAddToHexagon(edge1, connector3u4)); Assert.IsFalse(hexagon.IsComplete); HyperEdge false1 = new HyperEdge("00", "03", "30", TileOrientation.Flipped); hexagon = new Hexagon(edge2, TileFace.Right, connector1u2); Assert.IsFalse(hexagon.IsComplete); Assert.IsTrue(hexagon.TryAddToHexagon(edge3, connector3u4)); Assert.IsFalse(hexagon.IsComplete); Assert.IsTrue(hexagon.TryAddToHexagon(edge4, connector3u4)); Assert.IsFalse(hexagon.IsComplete); Assert.IsTrue(hexagon.TryAddToHexagon(edge5, connector0u5)); Assert.IsFalse(hexagon.IsComplete); Assert.IsTrue(hexagon.TryAddToHexagon(edge0, connector0u5)); Assert.IsFalse(hexagon.IsComplete); Assert.IsFalse(hexagon.TryAddToHexagon(false1, connector1u2)); Assert.IsFalse(hexagon.IsComplete); }
public static byte[] Serialize(this HyperEdge edge) => JsonSerializer.Serialize(edge);
public static Task SerializeAsync(this HyperEdge edge, Stream stream) => JsonSerializer.SerializeAsync(stream, edge);
public void HyperGraph_IsPartOfHexagon_has_to_work() { List <Vertex> vertices = new List <Vertex>(); List <HyperEdge> twoSidedEdges = new List <HyperEdge>(); for (int i = 0; i < 6; i++) { for (int j = i; j < 6; j++) { vertices.Add(new Vertex(i + "" + j)); if (i != j) { vertices.Add(new Vertex(j + "" + i)); } twoSidedEdges.Add(new HyperEdge(i + "" + j, j + "" + i)); } } HyperGraph hyperGraph = new HyperGraph(vertices); foreach (HyperEdge twoSidedEdge in twoSidedEdges) { hyperGraph.AddEdge(twoSidedEdge); } HyperEdge edge0 = new HyperEdge("00", "00", "00", TileOrientation.Straight); HyperEdge edge1 = new HyperEdge("00", "02", "20", TileOrientation.Flipped); HyperEdge edge2 = new HyperEdge("02", "22", "20", TileOrientation.DoubleTiltLeft); HyperEdge edge3 = new HyperEdge("01", "12", "20", TileOrientation.Flipped); HyperEdge edge4 = new HyperEdge("01", "11", "10", TileOrientation.DoubleTiltRight); HyperEdge edge5 = new HyperEdge("00", "01", "10", TileOrientation.TiltRight); List <Hexagon> hexagons = new List <Hexagon>(); HyperEdge addedEdge0 = hyperGraph.AddEdge(edge0); Assert.IsFalse(hyperGraph.IsPartOfHexagon(edge0, out hexagons)); Assert.AreEqual(0, hexagons.Count); Assert.IsTrue(hyperGraph.AddEdgeWithDirectNeighbor(edge1, edge0, out HyperEdge addedEdge1)); Assert.IsFalse(hyperGraph.IsPartOfHexagon(edge1, out hexagons)); Assert.AreEqual(0, hexagons.Count); Assert.IsTrue(hyperGraph.AddEdgeWithDirectNeighbor(edge2, edge1, out HyperEdge addedEdge2)); Assert.IsFalse(hyperGraph.IsPartOfHexagon(edge2, out hexagons)); Assert.AreEqual(0, hexagons.Count); Assert.IsTrue(hyperGraph.AddEdgeWithDirectNeighbor(edge3, edge2, out HyperEdge addedEdge3)); Assert.IsFalse(hyperGraph.IsPartOfHexagon(edge3, out hexagons)); Assert.AreEqual(0, hexagons.Count); Assert.IsTrue(hyperGraph.AddEdgeWithDirectNeighbor(edge4, edge3, out HyperEdge addedEdge4)); Assert.IsFalse(hyperGraph.IsPartOfHexagon(edge4, out hexagons)); Assert.AreEqual(0, hexagons.Count); Assert.IsTrue(hyperGraph.AddEdgeWithDirectNeighbor(edge5, edge4, out HyperEdge addedEdge5)); addedEdge5.AddDirectNeighbor(addedEdge0); Assert.IsTrue(hyperGraph.IsPartOfHexagon(edge5, out hexagons)); Assert.AreEqual(1, hexagons.Count); //----------------------------------------------------------------------------------- hyperGraph = new HyperGraph(vertices); foreach (HyperEdge twoSidedEdge in twoSidedEdges) { hyperGraph.AddEdge(twoSidedEdge); } addedEdge1 = hyperGraph.AddEdge(edge1); Assert.IsFalse(hyperGraph.IsPartOfHexagon(edge1, out hexagons)); Assert.AreEqual(0, hexagons.Count); Assert.IsTrue(hyperGraph.AddEdgeWithDirectNeighbor(edge2, edge1, out addedEdge2)); Assert.IsFalse(hyperGraph.IsPartOfHexagon(edge2, out hexagons)); Assert.AreEqual(0, hexagons.Count); Assert.IsTrue(hyperGraph.AddEdgeWithDirectNeighbor(edge3, edge2, out addedEdge3)); Assert.IsFalse(hyperGraph.IsPartOfHexagon(edge3, out hexagons)); Assert.AreEqual(0, hexagons.Count); Assert.IsTrue(hyperGraph.AddEdgeWithDirectNeighbor(edge4, edge3, out addedEdge4)); Assert.IsFalse(hyperGraph.IsPartOfHexagon(edge4, out hexagons)); Assert.AreEqual(0, hexagons.Count); Assert.IsTrue(hyperGraph.AddEdgeWithDirectNeighbor(edge5, edge4, out addedEdge5)); Assert.IsFalse(hyperGraph.IsPartOfHexagon(edge5, out hexagons)); Assert.AreEqual(0, hexagons.Count); Assert.IsTrue(hyperGraph.AddEdgeWithDirectNeighbor(edge0, edge5, out addedEdge0)); addedEdge0.AddDirectNeighbor(addedEdge1); Assert.IsTrue(hyperGraph.IsPartOfHexagon(edge0, out hexagons)); Assert.AreEqual(1, hexagons.Count); //----------------------------------------------------------------------------------- hyperGraph = new HyperGraph(vertices); foreach (HyperEdge twoSidedEdge in twoSidedEdges) { hyperGraph.AddEdge(twoSidedEdge); } addedEdge2 = hyperGraph.AddEdge(edge2); Assert.IsFalse(hyperGraph.IsPartOfHexagon(edge2, out hexagons)); Assert.AreEqual(0, hexagons.Count); Assert.IsTrue(hyperGraph.AddEdgeWithDirectNeighbor(edge3, edge2, out addedEdge3)); Assert.IsFalse(hyperGraph.IsPartOfHexagon(edge3, out hexagons)); Assert.AreEqual(0, hexagons.Count); Assert.IsTrue(hyperGraph.AddEdgeWithDirectNeighbor(edge4, edge3, out addedEdge4)); Assert.IsFalse(hyperGraph.IsPartOfHexagon(edge4, out hexagons)); Assert.AreEqual(0, hexagons.Count); Assert.IsTrue(hyperGraph.AddEdgeWithDirectNeighbor(edge5, edge4, out addedEdge5)); Assert.IsFalse(hyperGraph.IsPartOfHexagon(edge5, out hexagons)); Assert.AreEqual(0, hexagons.Count); Assert.IsTrue(hyperGraph.AddEdgeWithDirectNeighbor(edge0, edge5, out addedEdge0)); Assert.IsFalse(hyperGraph.IsPartOfHexagon(edge0, out hexagons)); Assert.AreEqual(0, hexagons.Count); Assert.IsTrue(hyperGraph.AddEdgeWithDirectNeighbor(edge1, edge0, out addedEdge1)); addedEdge1.AddDirectNeighbor(addedEdge2); Assert.IsTrue(hyperGraph.IsPartOfHexagon(edge1, out hexagons)); Assert.AreEqual(1, hexagons.Count); //----------------------------------------------------------------------------------- hyperGraph = new HyperGraph(vertices); foreach (HyperEdge twoSidedEdge in twoSidedEdges) { hyperGraph.AddEdge(twoSidedEdge); } addedEdge3 = hyperGraph.AddEdge(edge3); Assert.IsFalse(hyperGraph.IsPartOfHexagon(edge3, out hexagons)); Assert.AreEqual(0, hexagons.Count); Assert.IsTrue(hyperGraph.AddEdgeWithDirectNeighbor(edge4, edge3, out addedEdge4)); Assert.IsFalse(hyperGraph.IsPartOfHexagon(edge4, out hexagons)); Assert.AreEqual(0, hexagons.Count); Assert.IsTrue(hyperGraph.AddEdgeWithDirectNeighbor(edge5, edge4, out addedEdge5)); Assert.IsFalse(hyperGraph.IsPartOfHexagon(edge5, out hexagons)); Assert.AreEqual(0, hexagons.Count); Assert.IsTrue(hyperGraph.AddEdgeWithDirectNeighbor(edge0, edge5, out addedEdge0)); Assert.IsFalse(hyperGraph.IsPartOfHexagon(edge0, out hexagons)); Assert.AreEqual(0, hexagons.Count); Assert.IsTrue(hyperGraph.AddEdgeWithDirectNeighbor(edge1, edge0, out addedEdge1)); Assert.IsFalse(hyperGraph.IsPartOfHexagon(edge1, out hexagons)); Assert.AreEqual(0, hexagons.Count); Assert.IsTrue(hyperGraph.AddEdgeWithDirectNeighbor(edge2, edge1, out addedEdge2)); addedEdge2.AddDirectNeighbor(addedEdge3); Assert.IsTrue(hyperGraph.IsPartOfHexagon(edge2, out hexagons)); Assert.AreEqual(1, hexagons.Count); //----------------------------------------------------------------------------------- hyperGraph = new HyperGraph(vertices); foreach (HyperEdge twoSidedEdge in twoSidedEdges) { hyperGraph.AddEdge(twoSidedEdge); } addedEdge4 = hyperGraph.AddEdge(edge4); Assert.IsFalse(hyperGraph.IsPartOfHexagon(edge4, out hexagons)); Assert.AreEqual(0, hexagons.Count); Assert.IsTrue(hyperGraph.AddEdgeWithDirectNeighbor(edge5, edge4, out addedEdge5)); Assert.IsFalse(hyperGraph.IsPartOfHexagon(edge5, out hexagons)); Assert.AreEqual(0, hexagons.Count); Assert.IsTrue(hyperGraph.AddEdgeWithDirectNeighbor(edge0, edge5, out addedEdge0)); Assert.IsFalse(hyperGraph.IsPartOfHexagon(edge0, out hexagons)); Assert.AreEqual(0, hexagons.Count); Assert.IsTrue(hyperGraph.AddEdgeWithDirectNeighbor(edge1, edge0, out addedEdge1)); Assert.IsFalse(hyperGraph.IsPartOfHexagon(edge1, out hexagons)); Assert.AreEqual(0, hexagons.Count); Assert.IsTrue(hyperGraph.AddEdgeWithDirectNeighbor(edge2, edge1, out addedEdge2)); Assert.IsFalse(hyperGraph.IsPartOfHexagon(edge2, out hexagons)); Assert.AreEqual(0, hexagons.Count); Assert.IsTrue(hyperGraph.AddEdgeWithDirectNeighbor(edge3, edge2, out addedEdge3)); addedEdge3.AddDirectNeighbor(addedEdge4); Assert.IsTrue(hyperGraph.IsPartOfHexagon(edge3, out hexagons)); Assert.AreEqual(1, hexagons.Count); //----------------------------------------------------------------------------------- hyperGraph = new HyperGraph(vertices); foreach (HyperEdge twoSidedEdge in twoSidedEdges) { hyperGraph.AddEdge(twoSidedEdge); } addedEdge5 = hyperGraph.AddEdge(edge5); Assert.IsFalse(hyperGraph.IsPartOfHexagon(edge5, out hexagons)); Assert.AreEqual(0, hexagons.Count); Assert.IsTrue(hyperGraph.AddEdgeWithDirectNeighbor(edge0, edge5, out addedEdge0)); Assert.IsFalse(hyperGraph.IsPartOfHexagon(edge0, out hexagons)); Assert.AreEqual(0, hexagons.Count); Assert.IsTrue(hyperGraph.AddEdgeWithDirectNeighbor(edge1, edge0, out addedEdge1)); Assert.IsFalse(hyperGraph.IsPartOfHexagon(edge1, out hexagons)); Assert.AreEqual(0, hexagons.Count); Assert.IsTrue(hyperGraph.AddEdgeWithDirectNeighbor(edge2, edge1, out addedEdge2)); Assert.IsFalse(hyperGraph.IsPartOfHexagon(edge2, out hexagons)); Assert.AreEqual(0, hexagons.Count); Assert.IsTrue(hyperGraph.AddEdgeWithDirectNeighbor(edge3, edge2, out addedEdge3)); Assert.IsFalse(hyperGraph.IsPartOfHexagon(edge3, out hexagons)); Assert.AreEqual(0, hexagons.Count); Assert.IsTrue(hyperGraph.AddEdgeWithDirectNeighbor(edge4, edge3, out addedEdge4)); addedEdge4.AddDirectNeighbor(addedEdge5); Assert.IsTrue(hyperGraph.IsPartOfHexagon(edge4, out hexagons)); Assert.AreEqual(1, hexagons.Count); //---------------------------------------------------------------------------------- HyperEdge edge6 = new HyperEdge("02", "24", "40", TileOrientation.DoubleTiltLeft); HyperEdge edge7 = new HyperEdge("04", "45", "50", TileOrientation.TiltLeft); HyperEdge edge8 = new HyperEdge("05", "55", "50", TileOrientation.Straight); HyperEdge edge9 = new HyperEdge("00", "05", "50", TileOrientation.TiltLeft); hyperGraph = new HyperGraph(vertices); foreach (HyperEdge twoSidedEdge in twoSidedEdges) { hyperGraph.AddEdge(twoSidedEdge); } addedEdge1 = hyperGraph.AddEdge(edge1); Assert.IsFalse(hyperGraph.IsPartOfHexagon(edge1, out hexagons)); Assert.AreEqual(0, hexagons.Count); Assert.IsTrue(hyperGraph.AddEdgeWithDirectNeighbor(edge2, edge1, out addedEdge2)); Assert.IsFalse(hyperGraph.IsPartOfHexagon(edge2, out hexagons)); Assert.AreEqual(0, hexagons.Count); Assert.IsTrue(hyperGraph.AddEdgeWithDirectNeighbor(edge3, edge2, out addedEdge3)); Assert.IsFalse(hyperGraph.IsPartOfHexagon(edge3, out hexagons)); Assert.AreEqual(0, hexagons.Count); Assert.IsTrue(hyperGraph.AddEdgeWithDirectNeighbor(edge4, edge3, out addedEdge4)); Assert.IsFalse(hyperGraph.IsPartOfHexagon(edge4, out hexagons)); Assert.AreEqual(0, hexagons.Count); Assert.IsTrue(hyperGraph.AddEdgeWithDirectNeighbor(edge5, edge4, out addedEdge5)); Assert.IsFalse(hyperGraph.IsPartOfHexagon(edge5, out hexagons)); Assert.AreEqual(0, hexagons.Count); Assert.IsTrue(hyperGraph.AddEdgeWithDirectNeighbor(edge6, edge1, out HyperEdge addedEdge6)); Assert.IsFalse(hyperGraph.IsPartOfHexagon(edge6, out hexagons)); Assert.AreEqual(0, hexagons.Count); Assert.IsTrue(hyperGraph.AddEdgeWithDirectNeighbor(edge7, edge6, out HyperEdge addedEdge7)); Assert.IsFalse(hyperGraph.IsPartOfHexagon(edge7, out hexagons)); Assert.AreEqual(0, hexagons.Count); Assert.IsTrue(hyperGraph.AddEdgeWithDirectNeighbor(edge8, edge7, out HyperEdge addedEdge8)); Assert.IsFalse(hyperGraph.IsPartOfHexagon(edge8, out hexagons)); Assert.AreEqual(0, hexagons.Count); Assert.IsTrue(hyperGraph.AddEdgeWithDirectNeighbor(edge9, edge8, out HyperEdge addedEdge9)); Assert.IsFalse(hyperGraph.IsPartOfHexagon(edge9, out hexagons)); Assert.AreEqual(0, hexagons.Count); Assert.IsTrue(hyperGraph.AddEdgeWithDirectNeighbor(edge0, edge5, out addedEdge0)); addedEdge0.AddDirectNeighbor(addedEdge1); addedEdge0.AddDirectNeighbor(addedEdge9); Assert.IsTrue(hyperGraph.IsPartOfHexagon(edge0, out hexagons)); Assert.AreEqual(2, hexagons.Count); }
public HyperEdgeControl?GetEdgeControl(HyperEdge edge) { HyperEdgeControls.TryGetValue(edge, out var ec); return(ec); }
private Tuple <IVertex, List <Guid> > InstanciateVertexAndNeighbors(DbDataReader sqlReader, bool permuteSource = false, IVertex augmentNeighborhood = null, List <Guid> previousEdges = null) { int i = 0; VertexData origin = new VertexData(); List <EdgeData> edges = new List <EdgeData>(); List <VertexData> neighbors = new List <VertexData>(); while (sqlReader.Read()) { if (i == 0) { origin.id = Guid.Parse(sqlReader["origin_vertex_id"].ToString()); origin.typeInfo = sqlReader["origin_vertex_type_info"].ToString(); origin.content = sqlReader["origin_vertex_content"].ToString(); } EdgeData edge = new EdgeData(); edge.id = Guid.Parse(sqlReader["edge_id"].ToString()); edge.typeInfo = sqlReader["edge_type_info"].ToString(); edge.target = Guid.Parse(sqlReader["target_vertex_id"].ToString()); edges.Add(edge); VertexData nei = new VertexData(); nei.id = Guid.Parse(sqlReader["target_vertex_id"].ToString()); nei.typeInfo = sqlReader["target_vertex_type_info"].ToString(); nei.content = sqlReader["target_vertex_content"].ToString(); neighbors.Add(nei); i++; } foreach (VertexData vd in neighbors) { IVertex neighbor = new Vertex <SerializableString>( graphStore: provider, id: vd.id, type: types[vd.typeInfo], content: new SerializableString(vd.content), lang: "NONE"); if (!cache.ContainsKey(neighbor.ObjectId)) { cache.Add(neighbor.ObjectId, neighbor); } } foreach (EdgeData ed in edges) { List <Guid> linkedElements = permuteSource ? new List <Guid> { ed.target, origin.id } : new List <Guid> { origin.id, ed.target }; IEdge edge = new HyperEdge(ed.id, types[ed.typeInfo], provider, linkedElements); provider.EdgeStore.Cache(edge); } List <Guid> edgeGuidList = edges.Select(e => e.id).ToList(); if (augmentNeighborhood != null) { edgeGuidList.AddRange(previousEdges); } IVertex originVertex = new Vertex <SerializableString>( graphStore: provider, id: origin.id, linkedObjectIdList: edgeGuidList, type: types[origin.typeInfo], content: new SerializableString(origin.content), lang: "NONE"); if (!cache.ContainsKey(origin.id)) { cache.Add(origin.id, originVertex); } if (augmentNeighborhood != null) { if (!cache.ContainsKey(origin.id)) { cache.Add(origin.id, originVertex); } else { cache[origin.id] = originVertex; } } return(new Tuple <IVertex, List <Guid> >(originVertex, edgeGuidList)); }
public static HyperGraph GenerateTest1() { var graph = new HyperGraph("Testing"); var v1 = new Vertex("1"); var v2 = new Vertex("22"); var v3 = new Vertex("333"); var v4 = new Vertex("4444"); var v5 = new Vertex("55555"); var v6 = new Vertex("666666"); var v7 = new Vertex("7777777"); var v8 = new Vertex("88888888"); var v9 = new Vertex("999999999"); var v10 = new Vertex("1010101010"); var e1 = new HyperEdge { Vertices = { v1, v2, v3 }, Weight = 400 }; var e2 = new HyperEdge { Vertices = { v2, v3, v4 }, Weight = 500 }; var e3 = new HyperEdge { Vertices = { v3, v4, v5 }, Weight = 600 }; var e4 = new HyperEdge { Vertices = { v4, v5, v6 }, Weight = 700 }; var e5 = new HyperEdge { Vertices = { v5, v6, v7 }, Weight = 800 }; var e6 = new HyperEdge { Vertices = { v6, v7, v8 }, Weight = 900 }; var e7 = new HyperEdge { Vertices = { v7, v8, v9 }, Weight = 1000 }; var e8 = new HyperEdge { Vertices = { v8, v9, v10 }, Weight = 50000 }; var e9 = new HyperEdge { Vertices = { v9, v10, v1 }, Weight = 25000 }; var e10 = new HyperEdge { Vertices = { v10, v1, v2 }, Weight = 1000000 }; v1.HyperEdges.Add(e1); v1.HyperEdges.Add(e2); v1.HyperEdges.Add(e3); v2.HyperEdges.Add(e2); v2.HyperEdges.Add(e3); v2.HyperEdges.Add(e4); v3.HyperEdges.Add(e3); v3.HyperEdges.Add(e4); v3.HyperEdges.Add(e5); v4.HyperEdges.Add(e4); v4.HyperEdges.Add(e5); v4.HyperEdges.Add(e6); v5.HyperEdges.Add(e5); v5.HyperEdges.Add(e6); v5.HyperEdges.Add(e7); v6.HyperEdges.Add(e6); v6.HyperEdges.Add(e7); v6.HyperEdges.Add(e8); v7.HyperEdges.Add(e7); v7.HyperEdges.Add(e8); v7.HyperEdges.Add(e9); v8.HyperEdges.Add(e8); v8.HyperEdges.Add(e9); v8.HyperEdges.Add(e10); v9.HyperEdges.Add(e9); v9.HyperEdges.Add(e10); v9.HyperEdges.Add(e1); v10.HyperEdges.Add(e10); v10.HyperEdges.Add(e1); v10.HyperEdges.Add(e2); graph.Vertices.AddRange(new[] { v1, v2, v3, v4, v5, v6, v7, v8, v9, v10 }); graph.HyperEdges.AddRange(new[] { // new HyperEdge {Vertices = {v1, v2, v3, v4, v5, v6, v7, v8, v9, v10}, Weight = 500}, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, }); return(graph); }