Esempio n. 1
0
            public int CompareTo(object obj)
            {
                BuildingEdge edge = obj as BuildingEdge;

                if (edge == null)
                {
                    throw new ArgumentException("Object is not BuildingEdge.");
                }

                return(X.CompareTo(edge.X));
            }
Esempio n. 2
0
        internal static void ConnectGraph(Graph graph, int x)
        {
            Dictionary <BuildingCC, BuildingCC> changedIslands = new Dictionary <BuildingCC, BuildingCC>();

            for (int i = 1; i < graph.Nodes.Count; i++)
            {
                if (changedIslands.ContainsKey(graph.Nodes[i].cc)) //if the islands has already been changed, update it
                {
                    graph.Nodes[i].cc = changedIslands[graph.Nodes[i].cc];
                }
                if (i % x != 0)
                {
                    if (graph.Nodes[i].cc != graph.Nodes[i - 1].cc) //if we are in an island on one axis, connect it
                    {
                        changedIslands[graph.Nodes[i].cc] = graph.Nodes[i - 1].cc;
                        graph.Nodes[i].cc = graph.Nodes[i - 1].cc;
                        //add the edge
                        BuildingEdge e = new BuildingEdge(graph.Nodes[i], graph.Nodes[i - 1]);
                        graph.Edges.Add(e);
                        //build adjacencies
                        e.Nodes[0].AdjacentNodes.Add(e.Nodes[1]);
                        e.Nodes[1].AdjacentNodes.Add(e.Nodes[0]);
                    }
                }
                else
                {
                    if (graph.Nodes[i].cc != graph.Nodes[i - x].cc) //if we are in an island on one axis, connect it
                    {
                        changedIslands[graph.Nodes[i].cc] = graph.Nodes[i - x].cc;
                        graph.Nodes[i].cc = graph.Nodes[i - x].cc;
                        //add the edge
                        BuildingEdge e = new BuildingEdge(graph.Nodes[i], graph.Nodes[i - x]);
                        graph.Edges.Add(e);
                        //build adjacencies
                        e.Nodes[0].AdjacentNodes.Add(e.Nodes[1]);
                        e.Nodes[1].AdjacentNodes.Add(e.Nodes[0]);
                    }
                }
            }
        }