示例#1
0
        public void AddEdge(VertexOfTable tableFrom, VertexOfTable tableTo, int id)
        {
            AddVertexIfNonExist(tableFrom);
            AddVertexIfNonExist(tableTo);
            var edge = new Edge(_idDictionary[tableFrom.GetName()], _idDictionary[tableTo.GetName()], id);

            AddEdge(edge);
        }
示例#2
0
        public int GetIdOfVertex(VertexOfTable vertex)
        {
            var name = vertex.GetName();

            if (_idDictionary.ContainsKey(name))
            {
                return(_idDictionary[name]);
            }
            else
            {
                return(-1);
            }
        }
示例#3
0
        public void AddVertexIfNonExist(VertexOfTable vertex)
        {
            var nameOfTable = vertex.GetName();

            if (_idDictionary.ContainsKey(nameOfTable))
            {
                return;
            }

            _idDictionary[nameOfTable]            = _countVertex;
            _nameOfId[_idDictionary[nameOfTable]] = nameOfTable;

            _graph.Add(new List <Edge>());
            _nodes.Add(vertex);
            _countVertex++;
        }