Beispiel #1
0
        public void Paint(GraphicsLayer.IGraphics g, int width, int height)
        {
            lock (_ModifyListsToken)
            {
                if (ParametersDirty)
                {
                    var graph = new Algorithms.Graph(GetEdgeWeights());
                    var n     = Vertices.Count;

                    for (int i = 0; i < Vertices.Count; i++)
                    {
                        Vertices[i].IsUniversal = graph.Degree(i) == n - 1;
                    }

                    ParametersDirty = false;
                }

                var jj = 0;
                foreach (var v in _vertices)
                {
                    v.ParentIndex = jj++;
                    v.Paint(g, width, height);
                }

                jj = 0;
                foreach (var e in _edges)
                {
                    e.ParentIndex = jj++;
                    e.Paint(g, width, height);
                }
            }
        }
Beispiel #2
0
        public Graph(Algorithms.Graph g, List <Vector> position, bool directed = true)
            : this()
        {
            if (g.VertexWeight != null && g.VertexWeight.Count == g.N)
            {
                _vertices = g.Vertices.Select(v => new Vertex(position[v].X, position[v].Y, g.VertexWeight[v].ToString())).ToList();
            }
            else
            {
                _vertices = g.Vertices.Select(v => new Vertex(position[v].X, position[v].Y)).ToList();
            }
            _edges = new List <Edge>();

            for (int i = 0; i < g.N; i++)
            {
                for (int j = i + 1; j < g.N; j++)
                {
                    if (directed)
                    {
                        if (g.Directed[i, j])
                        {
                            _edges.Add(new Edge(_vertices[i], _vertices[j], Edge.Orientations.Forward));
                        }
                        else if (g.Adjacent[i, j])
                        {
                            _edges.Add(new Edge(_vertices[j], _vertices[i], Edge.Orientations.Forward));
                        }
                    }
                    else if (g.Adjacent[i, j])
                    {
                        _edges.Add(new Edge(_vertices[i], _vertices[j], Edge.Orientations.None));
                    }
                }
            }
        }
Beispiel #3
0
        public void DoOutDegreePlusOneLabeling()
        {
            var g = new Algorithms.Graph(_graph.GetEdgeWeights());

            for (int i = 0; i < _graph.Vertices.Count; i++)
            {
                _graph.Vertices[i].Label = (g.OutDegree(i) + 1).ToString();
            }

            Invalidate();
            GraphChanged();
        }
Beispiel #4
0
        public void DoIndexLabeling()
        {
            var g = new Algorithms.Graph(_graph.GetEdgeWeights());

            for (int i = 0; i < _graph.Vertices.Count; i++)
            {
                _graph.Vertices[i].Label = i.ToString();
            }

            Invalidate();
            GraphChanged();
        }
Beispiel #5
0
        public GraphPolynomial(Algorithms.Graph g)
        {
            _g = g;

            _priorNeighbors = new List <List <int> >();
            for (int w = 0; w < _g.N; w++)
            {
                _priorNeighbors.Add(new List <int>());
                for (int v = 0; v < w; v++)
                {
                    if (g[v, w])
                    {
                        _priorNeighbors[w].Add(v);
                    }
                }
            }
        }
Beispiel #6
0
        public static int GetSignSum(this Algorithms.Graph g, int[] power)
        {
            var gp = new GraphPolynomial(g);

            return(gp.GetSignSum(power));
        }
Beispiel #7
0
        public static int GetCoefficient(this Algorithms.Graph g, int[] power)
        {
            var gp = new GraphPolynomial(g);

            return(gp.GetCoefficient(power));
        }