Esempio n. 1
0
        virtual public GraphAdjListVertex <NAME> AddVertex(NAME v)
        {
            GraphAdjListVertex <NAME> vv = null;

            // NB: This code is very efficient if the name space
            // is integer, and has been preconstructed. Otherwise,
            // it will truly suck in speed.

            // Add name.
            NameSpace.Add(v);

            // Find bijection v into int domain.
            int iv = NameSpace.BijectFromBasetype(v);

            // Find node from int domain.
            if (iv >= VertexSpace.Length)
            {
                Array.Resize(ref VertexSpace, VertexSpace.Length * 2);
            }
            if (VertexSpace[iv] == null)
            {
                vv              = (GraphAdjListVertex <NAME>)CreateVertex();
                vv.Name         = v;
                vv._Graph       = this;
                VertexSpace[iv] = vv;
            }
            else
            {
                vv = VertexSpace[iv];
            }
            return(vv);
        }
Esempio n. 2
0
        virtual public GraphAdjListEdge <NAME> AddEdge(NAME f, NAME t)
        {
            GraphAdjListVertex <NAME> vf = AddVertex(f);
            GraphAdjListVertex <NAME> vt = AddVertex(t);
            // Create adjacency table entry for (f, t).
            int j = adj.Add(f, t);

            // Create EDGE with from/to.
            if (j >= EdgeSpace.Length)
            {
                Array.Resize(ref EdgeSpace, EdgeSpace.Length * 2);
            }
            if (EdgeSpace[j] == null)
            {
                GraphAdjListEdge <NAME> edge = CreateEdge();
                edge.to      = vt;
                edge.from    = vf;
                EdgeSpace[j] = edge;
                return(edge);
            }
            else
            {
                return(EdgeSpace[j]);
            }
        }
Esempio n. 3
0
            public IEnumerator <NAME> GetEnumerator()
            {
                int[] index = graph.adj.IndexSuccessors;
                int[] data  = graph.adj.DataSuccessors;
                int   n     = graph.NameSpace.BijectFromBasetype(name);
                GraphAdjListVertex <NAME> node = graph.VertexSpace[n];

                for (int i = index[n + 1] - 1; i >= index[n]; --i)
                {
                    int  d = data[i];
                    NAME c = graph.VertexSpace[d].Name;
                    yield return(c);
                }
            }
Esempio n. 4
0
 public TreeAdjListEdge(GraphAdjListVertex <NAME> f, GraphAdjListVertex <NAME> t)
     : base(f, t)
 {
 }
Esempio n. 5
0
        virtual protected GraphAdjListVertex <NAME> CreateVertex()
        {
            GraphAdjListVertex <NAME> vv = (GraphAdjListVertex <NAME>)Activator.CreateInstance(NODE, true);

            return(vv);
        }
Esempio n. 6
0
 public GraphAdjListEdge(GraphAdjListVertex <NAME> f, GraphAdjListVertex <NAME> t)
 {
     from = (GraphAdjListVertex <NAME>)f;
     to   = (GraphAdjListVertex <NAME>)t;
 }
Esempio n. 7
0
 virtual public void DeleteVertex(GraphAdjListVertex <NAME> vertex)
 {
 }