Exemplo n.º 1
0
        public override void addEdge(V v, V u, object value)
        {
            Edge <V> edge = new Edge <V>(isDirected, v, u, value);
            SeparateChainingHashMap <V, Edge <V> > hashMap = new SeparateChainingHashMap <V, Edge <V> >();

            hashMap.put(u, edge);
            adjacencyMap.Add(hashMap);
            base.addEdge(edge);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Implements a graph using the adjacency map approach.
        /// </summary>
        private void arrangeMap(List <V> v, List <Edge <V> > e)
        {
            for (int k = 0; k < v.Count; k++)
            {
                SeparateChainingHashMap <V, Edge <V> > hashMap = new SeparateChainingHashMap <V, Edge <V> >();
                List <Edge <V> > v_edges = getEdges(v[k]);

                if (v_edges != null)
                {
                    foreach (Edge <V> edge in v_edges)
                    {
                        V neighbour = edge.getEndpoints().Where(vert => !(vert.Equals(v[k]))).SingleOrDefault();
                        hashMap.put(neighbour, edge);
                    }
                }

                adjacencyMap.Add(hashMap);
            }
        }