Exemple #1
0
        public bool AddEdge(Vertex v1, Vertex v2, Edge.Orientations orientation, int multiplicity = 1, float thickness = 3, string style = "", string label = "")
        {
            if (v1 == v2)
            {
                // Not allowing self-loops for now.
                return(false);
            }

            if (!EdgeExists(v1, v2) && !EdgeExists(v2, v1))
            {
                lock (_ModifyListsToken)
                {
                    var edge = new Edge(v1, v2, orientation);
                    edge.Multiplicity = multiplicity;
                    edge.Thickness    = thickness;
                    edge.Style        = style;
                    edge.Label        = label;
                    if (_showEdgeIndices)
                    {
                        edge.ToggleIndex();
                    }
                    _edges.Add(edge);
                    ParametersDirty = true;

                    return(true);
                }
            }

            return(false);
        }
Exemple #2
0
        public SerializationEdge(Edge e, List <Vertex> vertices)
        {
            IndexV1      = vertices.IndexOf(e.V1);
            IndexV2      = vertices.IndexOf(e.V2);
            Orientation  = e.Orientation;
            Thickness    = e.Thickness;
            Multiplicity = e.Multiplicity;
            Style        = e.Style ?? "";
            Label        = e.Label ?? "";

            if (Style == "")
            {
                if (Orientation == Edge.Orientations.Forward)
                {
                    Style = e.Style = "post";
                }
                else if (Orientation == Edge.Orientations.Backward)
                {
                    Style = e.Style = "pre";
                }
            }
        }