public void EdgeBetweenness(HierarchicalUndirectedGraph hgraph){        
        Integer nodeCount = hgraph.getNodeCount();
        Integer edgeCount = hgraph.getEdgeCount();        
                                
//        int count = 0;
        for (Node s : hgraph.getNodes()) {
            Stack<Node> S = new Stack<Node>();                    
            
            LinkedList<Node>[] P = new LinkedList[nodeCount];            
            double[] theta = new double[nodeCount];
            int[] d = new int[nodeCount];
            for (int j =0; j<nodeCount; j++){
                P[j] = new LinkedList<Node>();
                theta[j] = 0;
                d[j] = -1;
            }
            
            int s_index = indices.get(s);
            theta[s_index] = 1;
            d[s_index] = 0;
            
            LinkedList<Node> Q = new LinkedList<Node>();
            Q.addLast(s);
            while(!Q.isEmpty()) {
                Node v =Q.removeFirst();
                S.push(v);
                int v_index = indices.get(v);
                
                EdgeIterable edgeIter = hgraph.getEdgesAndMetaEdges(v);
                for(Edge edge : edgeIter){
                    Node reachable = hgraph.getOpposite(v, edge);
                    int r_index = indices.get(reachable);
                    if (d[r_index] < 0) {
                        Q.addLast(reachable);
                        d[r_index] = d[v_index] + 1;
                    }
                    if (d[r_index] == (d[v_index] + 1)) {
                        theta[r_index] = theta[r_index] + theta[v_index];
                        P[r_index].addLast(v);
                    }
                }                
            }
            
            Double[] delta = new Double[nodeCount];                        
            
            while(!S.empty()){                                    
                Node w = S.pop();                                
                Integer w_index = indices.get(w);                
                ListIterator<Node> iter1 = P[w_index].listIterator();
                while(iter1.hasNext()){
                    Node u = iter1.next();                    
                    Integer u_index = indices.get(u);
                    Double c = (theta[u_index] / theta[w_index])*(1+ delta[w_index]);
                    delta[u_index] += c;                                        
                    Edge e = hgraph.getEdge(w, u);                                        
                    betweenness.put(e, betweenness.get(e)+c);   
                }                                               
            }
        }                                
    }