Esempio n. 1
0
 public void AddVertex(string name)
 {
     if (matrix.Contains(name) == false)
     {
         matrix.Add(new Vertex(name));
     }
 }
Esempio n. 2
0
        public void AddEdge(Point3D p1, Point3D p2)
        {
            Edges.Add(new Line3D(p1, p2));
            Point3D point1 = Vertices.Find(p => p == p1);
            Point3D point2 = Vertices.Find(p => p == p2);

            if (!AdjacencyMatrix.ContainsKey(point1))
            {
                AdjacencyMatrix.Add(point1, new List <Point3D> {
                    p2
                });
            }
            else
            {
                AdjacencyMatrix[point1].Add(p2);
            }
            if (!AdjacencyMatrix.ContainsKey(point2))
            {
                AdjacencyMatrix.Add(point2, new List <Point3D> {
                    p1
                });
            }
            else
            {
                AdjacencyMatrix[point2].Add(p1);
            }
        }
Esempio n. 3
0
 public Polyhedron(List <Point3D> points)
 {
     Vertices = points;
     foreach (var point in points)
     {
         AdjacencyMatrix.Add(point, new List <Point3D>());
     }
 }
Esempio n. 4
0
        private void Add(Dependency dependency, out Edge edge)
        {
            edge = null;
            INode source;
            bool  sourceFound = m_Tree.TryGet(dependency.Source.FullName, out source);

            if (!sourceFound)
            {
                return;
            }

            INode target;
            bool  targetFound = m_Tree.TryGet(dependency.Target.FullName, out target);

            if (!targetFound)
            {
                return;
            }

            m_Matrix.Add(source.Id, target.Id, dependency.Kind, out edge);
        }
Esempio n. 5
0
        private void MakeAdjacencyMatrix()
        {
            Rings = new List <List <Node> >();
            try
            {
                CenterNode = Nodes.Where(x => x.id == CenterNodeId).First();
                Rings.Add(new List <Node> {
                    CenterNode
                });
                for (int i = 0; i < Nodes.Count; i++)
                {
                    List <bool> bools = new List <bool>();
                    foreach (Node node in Nodes)
                    {
                        bools.Add(false);
                    }
                    AdjacencyMatrix.Add(bools);
                }
                foreach (Edge edge in Edges)
                {
                    AdjacencyMatrix[edge.from][edge.to] = true;
                }

                List <Node> ringOne = new List <Node>();
                Rings.Add(ringOne);

                List <Node> orderDrawn = new List <Node>();

                int edgeTo = 0;
                foreach (bool hasEdge in AdjacencyMatrix[CenterNode.id])
                {
                    if (hasEdge)
                    {
                        Node drawLineTo = Nodes[edgeTo];
                        ringOne.Add(drawLineTo);
                        orderDrawn.Add(drawLineTo);
                    }
                    edgeTo++;
                }

                while (orderDrawn.Count != 0)
                {
                    Dictionary <int, List <int> > edgeMap = new Dictionary <int, List <int> >();
                    List <Node> orderDrawnLocal           = new List <Node>(orderDrawn);
                    foreach (Node node in orderDrawnLocal)
                    {
                        orderDrawn = new List <Node>();
                        edgeTo     = 0;
                        List <Node> ringX = new List <Node>();
                        foreach (bool hasEdge in AdjacencyMatrix[node.id])
                        {
                            if (hasEdge && edgeTo != CenterNodeId && !orderDrawnLocal.Contains(Nodes[edgeTo]) && (edgeMap.ContainsKey(edgeTo) ? !edgeMap[edgeTo].Contains(node.id) : true))
                            {
                                if (!edgeMap.ContainsKey(node.id))
                                {
                                    edgeMap.Add(node.id, new List <int>());
                                }

                                edgeMap[node.id].Add(edgeTo);

                                Node drawLineTo = Nodes[edgeTo];
                                ringX.Add(drawLineTo);
                                orderDrawn.Add(drawLineTo);
                            }
                            edgeTo++;
                        }
                        if (ringX.Count != 0)
                        {
                            Rings.Add(ringX);
                        }
                    }
                }
                DrawRings();
            }
            catch (InvalidOperationException)
            {
                Errors.Add("CenterNodeId not found in Nodes");
                StateHasChanged();
            }
        }
Esempio n. 6
0
 public void AddVertex(Point3D point)
 {
     Vertices.Add(point);
     AdjacencyMatrix.Add(point, new List <Point3D>());
 }