//Search in the central floor object to find out what is behind a certain node
        //TODO add stoachastic variable for observing --> approximated edge length and
        public void ObserveRoom(int nodeID, CentralFloor floor)
        {
            List <int> incident = floor.Graph.Node(nodeID).GetIncident;

            foreach (int i in incident)
            {
                FloorGraphEdge e = floor.Graph.Edge(i);
                //Add edge
                if (!(fGraph.Edges.ContainsKey(i)))
                {
                    fGraph.AddEdge(e.Id, e.HardCopy());
                    fGraph.Node(nodeID).GetIncident.Add(i);
                }

                //Add node
                int dest = fGraph.Edge(i).GetDestination;
                if (!fGraph.Nodes.ContainsKey(dest))
                {
                    fGraph.AddNode(dest, new List <int> {
                        i
                    });
                }

                //Add references
                if (!fGraph.Node(dest).GetIncident.Contains(i))
                {
                    fGraph.Node(dest).GetIncident.Add(i);
                }
            }
        }
示例#2
0
        //Build the graph using the generated data structures and a DFS algorithm
        private void DFSGraphBuilder(Dictionary <int, List <int> > roomsPerDoor, Dictionary <int, List <int> > doorsPerRoom, Dictionary <int, bool> isExit, List <int> visited, int door = 1)
        {
            visited.Add(door);
            foreach (int room in roomsPerDoor[door])      //foreach connected room
            {
                foreach (int child in doorsPerRoom[room]) //for each door in that room
                {
                    if (!(visited.Contains(child)))
                    {
                        //Creat the node
                        //Add incoming and outgoing edge between nodes
                        //recurese on that node

                        fGraph.AddNode(child, new List <int>(), isExit[child]);
                        int edgeId1 = centralEdgeId++;
                        int edgeId2 = centralEdgeId++;
                        fGraph.AddEdge(edgeId1, room, child, door);
                        fGraph.AddEdge(edgeId2, room, door, child);
                        fGraph.Node(door).GetIncident.Add(edgeId1);
                        fGraph.Node(door).GetIncident.Add(edgeId2);
                        fGraph.Node(child).GetIncident.Add(edgeId1);
                        fGraph.Node(child).GetIncident.Add(edgeId2);

                        //Recurse on child
                        DFSGraphBuilder(roomsPerDoor, doorsPerRoom, isExit, visited, child);
                    }
                }
            }
        }