Beispiel #1
0
        /// <summary>
        ///
        /// </summary>
        public void Initialize(EdgeGraph graph)
        {
            _graph      = graph;
            _vertexObjs = new List <V>(_graph.VertexCount);
            for (int i = 0; i < _graph.VertexCount; i++)
            {
                _graph.AddVertex();
            }

            _edgeObjs    = new List <E>(_graph.EdgeCount);
            _vertices    = new Vector3[_graph.VertexCount];
            _lineindices = new List <int>();
        }
Beispiel #2
0
        /// <summary>
        ///
        /// </summary>
        public void Initialize(int vertexcount)
        {
            _graph      = new EdgeGraph(vertexcount);
            _vertexObjs = new List <V>(vertexcount);
            for (int i = 0; i < vertexcount; i++)
            {
                _graph.AddVertex();
            }

            _edgeObjs    = new List <E>();
            _vertices    = new Vector3[vertexcount];
            _lineindices = new List <int>();
        }
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public EdgeGraph ExtractEdgeGraph()
        {
            if (_model == null)
            {
                Initialize();
            }
            var g0 = _tileGraph.Graph;
            var g1 = new EdgeGraph(g0.VertexCount);

            for (int v0 = 0; v0 < g0.VertexCount; v0++)
            {
                g1.AddVertex();
            }

            var n = _map.TileDegree;

            for (int v0 = 0; v0 < g0.VertexCount; v0++)
            {
                var tile = _model.GetAssigned(v0);

                if (_applyTileFilter == true && _ignoreTiles.Contains(tile))
                {
                    continue;
                }

                for (int i = 0; i < n; i++)
                {
                    var label = _map.GetLabel(i, tile);

                    if (_labelSet.Contains(label))
                    {
                        int v1 = g0.GetVertexNeighborOut(v0, i);
                        if (v0 != v1)
                        {
                            if (!g1.HasEdge(v1, v0) && !g1.HasEdge(v0, v1))
                            {
                                g1.AddEdge(v0, v1);
                            }
                        }
                    }
                }
            }

            return(g1);
        }
        public EdgeGraph ExtractJointEdgeGraph()
        {
            if (_model == null)
            {
                Initialize();
            }

            var g0 = _tileGraph.Graph;
            var g1 = new EdgeGraph(g0.VertexCount);

            for (int v0 = 0; v0 < g0.VertexCount; v0++)
            {
                g1.AddVertex();
            }

            var n = _map.TileDegree;

            for (int v0 = 0; v0 < g0.VertexCount; v0++)
            {
                var tile = _model.GetAssigned(v0);

                for (int i = 0; i < n; i++)
                {
                    var label = _map.GetLabel(i, tile);

                    if (label != "0")
                    {
                        int v1 = g0.GetVertexNeighborOut(v0, i);
                        if (v0 != v1)
                        {
                            if (!g1.HasEdge(v1, v0) && !g1.HasEdge(v0, v1))
                            {
                                g1.AddEdge(v0, v1);
                            }
                        }
                    }
                }
            }

            return(g1);
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="position"></param>
 private void AddVertex(Vector3 position)
 {
     _graph.AddVertex();
     _positions.Add(position);
 }