public void MapCycleReducerMapsReducedCycleNodeBackToOriginalNodes() { //Build a graph with one nested cycles ConnectivityMap newMap = new ConnectivityMap(); newMap.AddRoomConnection(1, 2); newMap.AddRoomConnection(2, 3); //Cycle newMap.AddRoomConnection(3, 4); newMap.AddRoomConnection(4, 5); newMap.AddRoomConnection(3, 5); newMap.AddRoomConnection(5, 6); MapCycleReducer cycleReducer = new MapCycleReducer(newMap.RoomConnectionGraph.Edges); var roomMapping = cycleReducer.roomMappingNoCycleToFullMap; //Confirm that all the first node in the cycle maps back to all the collapsed nodes CollectionAssert.AreEquivalent(new List <int> { 3, 4, 5 }, roomMapping[3]); }
public void MapCycleReducerMapsContainsCorrectMappingForUnchangedEdgesInReducedMap() { //Build a graph with one nested cycles ConnectivityMap newMap = new ConnectivityMap(); newMap.AddRoomConnection(1, 2); newMap.AddRoomConnection(2, 3); //Cycle newMap.AddRoomConnection(3, 4); newMap.AddRoomConnection(4, 5); newMap.AddRoomConnection(3, 5); //Exterior connections newMap.AddRoomConnection(5, 6); newMap.AddRoomConnection(6, 7); MapCycleReducer cycleReducer = new MapCycleReducer(newMap.RoomConnectionGraph.Edges); var edgeMapping = cycleReducer.edgeMappingNoCycleToFullMap; Assert.AreEqual(new Connection(1, 2), edgeMapping[new Connection(1, 2)].Ordered); Assert.AreEqual(new Connection(2, 3), edgeMapping[new Connection(2, 3)].Ordered); Assert.AreEqual(new Connection(6, 7), edgeMapping[new Connection(6, 7)].Ordered); }
public void SingleCycleInMapCanBeRetrievedWhenCycleSpecifiedInADifferentOrder() { //Build a graph with one nested cycle ConnectivityMap newMap = new ConnectivityMap(); newMap.AddRoomConnection(1, 2); newMap.AddRoomConnection(2, 3); //Cycle newMap.AddRoomConnection(3, 5); newMap.AddRoomConnection(5, 4); newMap.AddRoomConnection(4, 3); newMap.AddRoomConnection(5, 6); MapCycleReducer cycleReducer = new MapCycleReducer(newMap.RoomConnectionGraph.Edges); var allCycles = cycleReducer.AllCycles; var expectedCycles = new List <List <Connection> > { new List <Connection> { new Connection(3, 5), new Connection(5, 4), new Connection(4, 3) } }; //Can't know whether the list will be returned in 'clockwise' or 'anticlockwise' ordering Assert.AreEqual(allCycles.Count, expectedCycles.Count); CollectionAssert.AreEquivalent(allCycles[0], expectedCycles[0]); }
public void MapCycleReducerMapsNonReducedNodeBackToThemselves() { //Build a graph with one nested cycles ConnectivityMap newMap = new ConnectivityMap(); newMap.AddRoomConnection(1, 2); newMap.AddRoomConnection(2, 3); //Cycle newMap.AddRoomConnection(3, 4); newMap.AddRoomConnection(4, 5); newMap.AddRoomConnection(3, 5); newMap.AddRoomConnection(5, 6); MapCycleReducer cycleReducer = new MapCycleReducer(newMap.RoomConnectionGraph.Edges); var roomMapping = cycleReducer.roomMappingNoCycleToFullMap; //Confirm that all the first node in the cycle maps back to all the collapsed nodes CollectionAssert.AreEquivalent(new List <int>(new int[] { 1 }), roomMapping[1]); CollectionAssert.AreEquivalent(new List <int>(new int[] { 2 }), roomMapping[2]); CollectionAssert.AreEquivalent(new List <int>(new int[] { 6 }), roomMapping[6]); }
public void MapCycleReducerRemovesOneCycleInInputMap() { //Build a graph with one nested cycle ConnectivityMap newMap = new ConnectivityMap(); newMap.AddRoomConnection(1, 2); newMap.AddRoomConnection(2, 3); //Cycle newMap.AddRoomConnection(3, 4); newMap.AddRoomConnection(4, 5); newMap.AddRoomConnection(3, 5); newMap.AddRoomConnection(5, 6); MapCycleReducer cycleReducer = new MapCycleReducer(newMap.RoomConnectionGraph.Edges); var roomMapping = cycleReducer.roomMappingFullToNoCycleMap; //Confirm that all the cycle nodes are mapped to the first node Assert.AreEqual(roomMapping[3], 3); Assert.AreEqual(roomMapping[4], 3); Assert.AreEqual(roomMapping[5], 3); }
public void MapWithTwoNonConnectedCyclesGivesTwoCyclesInAllCycles() { //Build a graph with one nested cycle ConnectivityMap newMap = new ConnectivityMap(); newMap.AddRoomConnection(1, 2); newMap.AddRoomConnection(2, 3); //Cycle 1 newMap.AddRoomConnection(3, 5); newMap.AddRoomConnection(5, 4); newMap.AddRoomConnection(4, 3); newMap.AddRoomConnection(5, 6); //Cycle 2 newMap.AddRoomConnection(6, 7); newMap.AddRoomConnection(7, 8); newMap.AddRoomConnection(8, 6); MapCycleReducer cycleReducer = new MapCycleReducer(newMap.RoomConnectionGraph.Edges); var allCycles = cycleReducer.AllCycles; Assert.AreEqual(2, allCycles.Count); }
public void ConnectionsOfMultipleDepthFromDeadEndFinalRoomsCanBeFound() { var standardMap = BuildBranchingTestMap(); var mapNoCycles = new MapCycleReducer(standardMap.RoomConnectionGraph.Edges); var mapH = new MapHeuristics(mapNoCycles, 1); var expectedConnections = new Dictionary<int, List<Connection>> { {0, new List<Connection>(new Connection[]{ new Connection(1, 2), new Connection(5, 6), new Connection(13, 14), new Connection(13, 15), new Connection(16, 17), new Connection(12, 18) })}, {1, new List<Connection>(new Connection[]{ new Connection(3, 5), new Connection(11, 12), new Connection(4, 16)})}, {2, new List<Connection>(new Connection[]{ new Connection(3, 4)})} }; var terminalConnectionsFound = mapH.GetTerminalBranchConnections(); CollectionAssert.AreEquivalent(expectedConnections[0], terminalConnectionsFound[0]); CollectionAssert.AreEquivalent(expectedConnections[1], terminalConnectionsFound[1]); CollectionAssert.AreEquivalent(expectedConnections[2], terminalConnectionsFound[2]); CollectionAssert.AreEquivalent(expectedConnections.Keys, terminalConnectionsFound.Keys); }
public void ConnectionsOfMultipleDepthFromDeadEndFinalRoomsCanBeFound() { var standardMap = BuildBranchingTestMap(); var mapNoCycles = new MapCycleReducer(standardMap.RoomConnectionGraph.Edges); var mapH = new MapHeuristics(mapNoCycles, 1); var expectedConnections = new Dictionary <int, List <Connection> > { { 0, new List <Connection>(new Connection[] { new Connection(1, 2), new Connection(5, 6), new Connection(13, 14), new Connection(13, 15), new Connection(16, 17), new Connection(12, 18) }) }, { 1, new List <Connection>(new Connection[] { new Connection(3, 5), new Connection(11, 12), new Connection(4, 16) }) }, { 2, new List <Connection>(new Connection[] { new Connection(3, 4) }) } }; var terminalConnectionsFound = mapH.GetTerminalBranchConnections(); CollectionAssert.AreEquivalent(expectedConnections[0], terminalConnectionsFound[0]); CollectionAssert.AreEquivalent(expectedConnections[1], terminalConnectionsFound[1]); CollectionAssert.AreEquivalent(expectedConnections[2], terminalConnectionsFound[2]); CollectionAssert.AreEquivalent(expectedConnections.Keys, terminalConnectionsFound.Keys); }
public void MapCycleReducerMapsContainsAMappingForEachEdgeInReducedMap() { //Build a graph with one nested cycles ConnectivityMap newMap = new ConnectivityMap(); newMap.AddRoomConnection(1, 2); newMap.AddRoomConnection(2, 3); //Cycle newMap.AddRoomConnection(3, 4); newMap.AddRoomConnection(4, 5); newMap.AddRoomConnection(3, 5); //Exterior connections newMap.AddRoomConnection(5, 6); newMap.AddRoomConnection(4, 7); newMap.AddRoomConnection(4, 8); newMap.AddRoomConnection(3, 9); MapCycleReducer cycleReducer = new MapCycleReducer(newMap.RoomConnectionGraph.Edges); Assert.AreEqual(6, cycleReducer.edgeMappingNoCycleToFullMap.Count()); }
private MapHeuristics BuildMapHeuristics() { var standardMap = BuildStandardTestMap(); var mapNoCycles = new MapCycleReducer(standardMap.RoomConnectionGraph.Edges); return(new MapHeuristics(mapNoCycles, 1)); }
private DoorAndClueManager BuildStandardManager() { var standardMap = BuildStandardTestMap(); var mapNoCycles = new MapCycleReducer(standardMap.RoomConnectionGraph.Edges); var mapMST = new MapMST(mapNoCycles.mapNoCycles.Edges); return(new DoorAndClueManager(mapNoCycles, 1)); }
public DoorAndClueManager(MapCycleReducer reducedMap, int startVertex) { this.mapNoCycles = reducedMap; this.startVertex = startVertex; lockDependencyGraph = new AdjacencyGraph<int, Edge<int>>(); doorMap = new Dictionary<int, Door>(); clueMap = new Dictionary<int, List<Clue>>(); objectiveMap = new Dictionary<int, Objective>(); objectiveRoomMap = new Dictionary<int, List<Objective>>(); }
public void CluesCanBePlacedInRoomIfOnlyOneRoomPossible() { ConnectivityMap newMap = new ConnectivityMap(); newMap.AddRoomConnection(1, 2); var mapNoCycles = new MapCycleReducer(newMap.RoomConnectionGraph.Edges); var mapMST = new MapMST(mapNoCycles.mapNoCycles.Edges); var manager = new DoorAndClueManager(mapNoCycles, 1); Assert.IsNotNull(manager.PlaceDoorAndClue(new DoorRequirements(new Connection(1, 2), "lock0"), 1)); }
public void MapCycleReducerRemovesMultipleCyclesInInputMap() { //Build a graph with one two nested cycles ConnectivityMap newMap = new ConnectivityMap(); newMap.AddRoomConnection(1, 2); newMap.AddRoomConnection(2, 3); //Cycle newMap.AddRoomConnection(3, 4); newMap.AddRoomConnection(4, 5); newMap.AddRoomConnection(3, 5); newMap.AddRoomConnection(5, 6); //Cycle newMap.AddRoomConnection(6, 7); newMap.AddRoomConnection(7, 8); newMap.AddRoomConnection(8, 9); newMap.AddRoomConnection(9, 10); newMap.AddRoomConnection(10, 11); newMap.AddRoomConnection(11, 6); newMap.AddRoomConnection(9, 6); newMap.AddRoomConnection(11, 12); MapCycleReducer cycleReducer = new MapCycleReducer(newMap.RoomConnectionGraph.Edges); var roomMapping = cycleReducer.roomMappingFullToNoCycleMap; //Confirm that all the first cycle nodes are mapped to the first node in the cycle Assert.AreEqual(3, roomMapping[3]); Assert.AreEqual(3, roomMapping[4]); Assert.AreEqual(3, roomMapping[5]); //Confirm that all the second cycle nodes are mapped to the first node in the second cycle Assert.AreEqual(6, roomMapping[6]); Assert.AreEqual(6, roomMapping[7]); Assert.AreEqual(6, roomMapping[8]); Assert.AreEqual(6, roomMapping[9]); Assert.AreEqual(6, roomMapping[10]); Assert.AreEqual(6, roomMapping[11]); }
public void RoomsOfMultipleDepthFromDeadEndFinalRoomsCanBeFound() { var standardMap = BuildBranchingTestMap(); var mapNoCycles = new MapCycleReducer(standardMap.RoomConnectionGraph.Edges); var mapH = new MapHeuristics(mapNoCycles, 1); var expectedNodes = new Dictionary <int, List <int> > { { 0, new List <int>(new int[] { 1, 6, 14, 15, 17, 18 }) }, { 1, new List <int>(new int[] { 5, 12, 16 }) }, { 2, new List <int>(new int[] { 4 }) } }; var terminalNodesFound = mapH.GetTerminalBranchNodes(); CollectionAssert.AreEquivalent(expectedNodes[0], terminalNodesFound[0]); CollectionAssert.AreEquivalent(expectedNodes[1], terminalNodesFound[1]); CollectionAssert.AreEquivalent(expectedNodes[2], terminalNodesFound[2]); CollectionAssert.AreEquivalent(expectedNodes.Keys, terminalNodesFound.Keys); }
public void SquashedEdgeIsNotInMapAfterCycleReduction() { //Build a graph with one nested cycle ConnectivityMap newMap = new ConnectivityMap(); newMap.AddRoomConnection(1, 2); newMap.AddRoomConnection(2, 3); //Cycle newMap.AddRoomConnection(3, 4); newMap.AddRoomConnection(4, 5); newMap.AddRoomConnection(3, 5); newMap.AddRoomConnection(5, 6); MapCycleReducer cycleReducer = new MapCycleReducer(newMap.RoomConnectionGraph.Edges); Assert.IsFalse(cycleReducer.IsEdgeInRoomsNoCycles(3, 4)); }
public void RemovedEdgeNotFoundInMapCycleReducer() { //Build a graph with one nested cycle ConnectivityMap newMap = new ConnectivityMap(); newMap.AddRoomConnection(1, 2); newMap.AddRoomConnection(2, 3); //Cycle newMap.AddRoomConnection(3, 4); newMap.AddRoomConnection(4, 5); newMap.AddRoomConnection(3, 5); newMap.AddRoomConnection(5, 6); MapCycleReducer cycleReducer = new MapCycleReducer(newMap.RoomConnectionGraph.Edges); cycleReducer.GetEdgeBetweenRoomsNoCycles(4, 5); }
public void EdgeTraversingCycleIsInMapAfterCycleReduction() { //Build a graph with one nested cycle ConnectivityMap newMap = new ConnectivityMap(); newMap.AddRoomConnection(1, 2); newMap.AddRoomConnection(2, 3); //Cycle newMap.AddRoomConnection(3, 4); newMap.AddRoomConnection(4, 5); newMap.AddRoomConnection(3, 5); newMap.AddRoomConnection(5, 6); MapCycleReducer cycleReducer = new MapCycleReducer(newMap.RoomConnectionGraph.Edges); Assert.IsTrue(cycleReducer.IsEdgeInRoomsNoCycles(3, 6)); }
public void MapWithTwoNestedCyclesGivesCorrectTwoCyclesInAllCycles() { //Build a graph with one nested cycle ConnectivityMap newMap = new ConnectivityMap(); newMap.AddRoomConnection(1, 2); newMap.AddRoomConnection(2, 3); //Cycle 1 newMap.AddRoomConnection(3, 5); newMap.AddRoomConnection(5, 4); newMap.AddRoomConnection(4, 3); //Nested cycle newMap.AddRoomConnection(4, 6); newMap.AddRoomConnection(5, 6); MapCycleReducer cycleReducer = new MapCycleReducer(newMap.RoomConnectionGraph.Edges); //Relying on the fact that the DFS hits 3,5 first var allCycles = cycleReducer.AllCycles; var expectedCycles = new List <List <Connection> > { new List <Connection> { new Connection(3, 5), new Connection(5, 4), new Connection(4, 3) }, new List <Connection> { new Connection(4, 6), new Connection(6, 5), new Connection(5, 4) } }; Assert.AreEqual(2, allCycles.Count); CollectionAssert.AreEquivalent(expectedCycles[0], allCycles[0]); CollectionAssert.AreEquivalent(expectedCycles[1], allCycles[1]); }
public void DeadEndNodesAreFoundInSinglePathGraphs() { ConnectivityMap newMap = new ConnectivityMap(); newMap.AddRoomConnection(1, 2); newMap.AddRoomConnection(2, 3); var mapNoCycles = new MapCycleReducer(newMap.RoomConnectionGraph.Edges); var mapH = new MapHeuristics(mapNoCycles, 1); var expectedConnections = new Dictionary<int, List<Connection>> { {0, new List<Connection>(new Connection[]{ new Connection(1, 2), new Connection(2, 3)})} }; var terminalConnectionsFound = mapH.GetTerminalBranchConnections(); //TODO: We have slightly pathological behaviour that all non-terminal node connections //will be double counted in the CollectionAssert.AreEquivalent(expectedConnections[0], terminalConnectionsFound[0]); CollectionAssert.AreEquivalent(expectedConnections.Keys, terminalConnectionsFound.Keys); }
public void EdgeBetweenNonCycleAndCycleMapsToBottleneckEdge() { //Build a graph with one nested cycle ConnectivityMap newMap = new ConnectivityMap(); newMap.AddRoomConnection(1, 2); newMap.AddRoomConnection(2, 3); //Cycle newMap.AddRoomConnection(3, 4); newMap.AddRoomConnection(4, 5); newMap.AddRoomConnection(3, 5); newMap.AddRoomConnection(5, 6); MapCycleReducer cycleReducer = new MapCycleReducer(newMap.RoomConnectionGraph.Edges); //In the reduced graph, we have the edge between the first node of the cycle and the next node //In the full graph, we have the bottleneck edge between the cycle and the next node Assert.AreEqual(cycleReducer.edgeMappingNoCycleToFullMap[new Connection(3, 6)], new Connection(5, 6)); }
public void DeadEndNodesAreFoundInSinglePathGraphs() { ConnectivityMap newMap = new ConnectivityMap(); newMap.AddRoomConnection(1, 2); newMap.AddRoomConnection(2, 3); var mapNoCycles = new MapCycleReducer(newMap.RoomConnectionGraph.Edges); var mapH = new MapHeuristics(mapNoCycles, 1); var expectedConnections = new Dictionary <int, List <Connection> > { { 0, new List <Connection>(new Connection[] { new Connection(1, 2), new Connection(2, 3) }) } }; var terminalConnectionsFound = mapH.GetTerminalBranchConnections(); //TODO: We have slightly pathological behaviour that all non-terminal node connections //will be double counted in the CollectionAssert.AreEquivalent(expectedConnections[0], terminalConnectionsFound[0]); CollectionAssert.AreEquivalent(expectedConnections.Keys, terminalConnectionsFound.Keys); }
public void MapCycleReducerMapsExterorEdgesOfCycleToOriginalConnections() { //Build a graph with one nested cycles ConnectivityMap newMap = new ConnectivityMap(); newMap.AddRoomConnection(1, 2); newMap.AddRoomConnection(2, 3); //Cycle newMap.AddRoomConnection(3, 4); newMap.AddRoomConnection(4, 5); newMap.AddRoomConnection(3, 5); //Exterior connections newMap.AddRoomConnection(5, 6); newMap.AddRoomConnection(4, 7); newMap.AddRoomConnection(4, 8); newMap.AddRoomConnection(3, 9); MapCycleReducer cycleReducer = new MapCycleReducer(newMap.RoomConnectionGraph.Edges); var edgeMapping = cycleReducer.edgeMappingNoCycleToFullMap; //Exterior connections from start node Assert.AreEqual(new Connection(2, 3), edgeMapping[new Connection(2, 3)].Ordered); Assert.AreEqual(new Connection(3, 9), edgeMapping[new Connection(3, 9)].Ordered); //Exterior connections from collasped nodes Assert.AreEqual(new Connection(4, 7), edgeMapping[new Connection(3, 7)].Ordered); Assert.AreEqual(new Connection(4, 8), edgeMapping[new Connection(3, 8)].Ordered); Assert.AreEqual(new Connection(5, 6), edgeMapping[new Connection(3, 6)].Ordered); }
private DoorAndClueManager BuildStandardManager() { var standardMap = BuildStandardTestMap(); var mapNoCycles = new MapCycleReducer(standardMap.RoomConnectionGraph.Edges); var mapMST = new MapMST(mapNoCycles.mapNoCycles.Edges); return new DoorAndClueManager(mapNoCycles, 1); }
public void RoomsOfMultipleDepthFromDeadEndFinalRoomsCanBeFound() { var standardMap = BuildBranchingTestMap(); var mapNoCycles = new MapCycleReducer(standardMap.RoomConnectionGraph.Edges); var mapH = new MapHeuristics(mapNoCycles, 1); var expectedNodes = new Dictionary<int, List<int>> { {0, new List<int>(new int[]{1, 6, 14, 15, 17, 18})}, {1, new List<int>(new int[]{5, 12, 16})}, {2, new List<int>(new int[]{4})} }; var terminalNodesFound = mapH.GetTerminalBranchNodes(); CollectionAssert.AreEquivalent(expectedNodes[0], terminalNodesFound[0]); CollectionAssert.AreEquivalent(expectedNodes[1], terminalNodesFound[1]); CollectionAssert.AreEquivalent(expectedNodes[2], terminalNodesFound[2]); CollectionAssert.AreEquivalent(expectedNodes.Keys, terminalNodesFound.Keys); }
private MapHeuristics BuildMapHeuristics() { var standardMap = BuildStandardTestMap(); var mapNoCycles = new MapCycleReducer(standardMap.RoomConnectionGraph.Edges); return new MapHeuristics(mapNoCycles, 1); }
public void SingleCycleInMapCanBeRetrievedWhenCycleSpecifiedInADifferentOrder() { //Build a graph with one nested cycle ConnectivityMap newMap = new ConnectivityMap(); newMap.AddRoomConnection(1, 2); newMap.AddRoomConnection(2, 3); //Cycle newMap.AddRoomConnection(3, 5); newMap.AddRoomConnection(5, 4); newMap.AddRoomConnection(4, 3); newMap.AddRoomConnection(5, 6); MapCycleReducer cycleReducer = new MapCycleReducer(newMap.RoomConnectionGraph.Edges); var allCycles = cycleReducer.AllCycles; var expectedCycles = new List<List<Connection>> { new List<Connection> { new Connection(3,5), new Connection(5,4), new Connection(4,3) }}; //Can't know whether the list will be returned in 'clockwise' or 'anticlockwise' ordering Assert.AreEqual(allCycles.Count, expectedCycles.Count); CollectionAssert.AreEquivalent(allCycles[0], expectedCycles[0]); }
public void MapCycleReducerMapsNonReducedNodeBackToThemselves() { //Build a graph with one nested cycles ConnectivityMap newMap = new ConnectivityMap(); newMap.AddRoomConnection(1, 2); newMap.AddRoomConnection(2, 3); //Cycle newMap.AddRoomConnection(3, 4); newMap.AddRoomConnection(4, 5); newMap.AddRoomConnection(3, 5); newMap.AddRoomConnection(5, 6); MapCycleReducer cycleReducer = new MapCycleReducer(newMap.RoomConnectionGraph.Edges); var roomMapping = cycleReducer.roomMappingNoCycleToFullMap; //Confirm that all the first node in the cycle maps back to all the collapsed nodes CollectionAssert.AreEquivalent(new List<int>(new int[] { 1 }), roomMapping[1]); CollectionAssert.AreEquivalent(new List<int>(new int[] { 2 }), roomMapping[2]); CollectionAssert.AreEquivalent(new List<int>(new int[] { 6 }), roomMapping[6]); }
public void MapWithTwoNestedCyclesGivesCorrectTwoCyclesInAllCycles() { //Build a graph with one nested cycle ConnectivityMap newMap = new ConnectivityMap(); newMap.AddRoomConnection(1, 2); newMap.AddRoomConnection(2, 3); //Cycle 1 newMap.AddRoomConnection(3, 5); newMap.AddRoomConnection(5, 4); newMap.AddRoomConnection(4, 3); //Nested cycle newMap.AddRoomConnection(4, 6); newMap.AddRoomConnection(5, 6); MapCycleReducer cycleReducer = new MapCycleReducer(newMap.RoomConnectionGraph.Edges); //Relying on the fact that the DFS hits 3,5 first var allCycles = cycleReducer.AllCycles; var expectedCycles = new List<List<Connection>> { new List<Connection> { new Connection(3,5), new Connection(5,4), new Connection(4,3) }, new List<Connection> { new Connection(4,6), new Connection(6,5), new Connection(5,4) } }; Assert.AreEqual(2, allCycles.Count); CollectionAssert.AreEquivalent(expectedCycles[0], allCycles[0]); CollectionAssert.AreEquivalent(expectedCycles[1], allCycles[1]); }
public MapHeuristics(MapCycleReducer mapWithoutCycles, int startVertex) { this.mapWithoutCycles = mapWithoutCycles; this.startVertex = startVertex; }
public void MapCycleReducerMapsReducedCycleNodeBackToOriginalNodes() { //Build a graph with one nested cycles ConnectivityMap newMap = new ConnectivityMap(); newMap.AddRoomConnection(1, 2); newMap.AddRoomConnection(2, 3); //Cycle newMap.AddRoomConnection(3, 4); newMap.AddRoomConnection(4, 5); newMap.AddRoomConnection(3, 5); newMap.AddRoomConnection(5, 6); MapCycleReducer cycleReducer = new MapCycleReducer(newMap.RoomConnectionGraph.Edges); var roomMapping = cycleReducer.roomMappingNoCycleToFullMap; //Confirm that all the first node in the cycle maps back to all the collapsed nodes CollectionAssert.AreEquivalent(new List<int>{ 3, 4, 5 }, roomMapping[3]); }