当前位置: 首页>>代码示例>>Java>>正文


Java SimpleGraph.getEdgeSource方法代码示例

本文整理汇总了Java中org.jgrapht.graph.SimpleGraph.getEdgeSource方法的典型用法代码示例。如果您正苦于以下问题:Java SimpleGraph.getEdgeSource方法的具体用法?Java SimpleGraph.getEdgeSource怎么用?Java SimpleGraph.getEdgeSource使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jgrapht.graph.SimpleGraph的用法示例。


在下文中一共展示了SimpleGraph.getEdgeSource方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: enumerateCliques

import org.jgrapht.graph.SimpleGraph; //导入方法依赖的package包/类
/**
 * 
 * @param g The graph where the largest clique needs to be found
 * @param c Set of vertices belonging to the current clique
 * @param p Set of vertices which can be added to C
 * @param s set of vertices which are not allowed to be added to C
 * @return the largest clique in graph g
 */
private static <V,E> Set<V> enumerateCliques(SimpleGraph<V,E> g, Set<V> c, Set<V> p, int currentmaxresult){
	if(interruptFlag) return null;
    Set<V> result = new LinkedHashSet<V>(c);
    if(p.isEmpty() || p.size() + c.size() <= currentmaxresult){ //if p=EMPTY and s=EMPTY
    	//check for s.isEmpty is removed because the code will return the same result if only P is empty
    	//added p.size() + c.size() <= currentmaxresult, if this is true, then the new clique can not be bigger then the clique that has already been found
        return result;                                   //REPORT.CLIQUE
    } else {
        List<V> pList = new ArrayList<V>(p);
        V ut = pList.get(0);                           	 //Let ut be a vertex from P
        for(V currentVertex : p){                        //for i <- 1 to k
            if(!g.containsEdge(ut, currentVertex)){      //if ui is not adjacent ut ut
                pList.remove(currentVertex);             //P <-P\{ui}
                Set<V> pNext = new LinkedHashSet<V>(pList);    //P' <- P
                Set<V> n = new LinkedHashSet<V>();
                for(E edge : g.edgesOf(currentVertex)){
                    V neighbour = g.getEdgeSource(edge);
                    if(neighbour.equals(currentVertex)){
                        neighbour = g.getEdgeTarget(edge);
                    }
                    n.add(neighbour);
                }                                        //N <- { v ELEMENTOF V | {ui,v} ELEMENTOF E }

                Set<V> cNext = new LinkedHashSet<V>(c);
                cNext.add(currentVertex);                //C UNION {ui}
                pNext.retainAll(n);                      //P' INTERSECTION N
                
                Set<V> clique = enumerateCliques(g, cNext, pNext, currentmaxresult); //ENUMERATE.CLIQUES....
                if(clique.size() > result.size()){
                    result = clique;
                    currentmaxresult = clique.size();
                }
            }
        }
    }
    return result;
}
 
开发者ID:WellingR,项目名称:Maximal-Common-Subgraph,代码行数:46,代码来源:Algorithm2.java

示例2: neighbourVertices

import org.jgrapht.graph.SimpleGraph; //导入方法依赖的package包/类
/**
 * 
 * @param u a Vertex of g
 * @return {v ELEMENTOF V | {u,v} ELEMENTOF E}
 */
private static <V,E> Set<V> neighbourVertices(SimpleGraph<V,E> g, V u){
	Set<V> result = new LinkedHashSet<V>();
	for(E edge : g.edgesOf(u)){
        V neighbour = g.getEdgeSource(edge);
        if(neighbour.equals(u)){
            neighbour = g.getEdgeTarget(edge);
        }
        result.add(neighbour);
        
    }
	return result;
}
 
开发者ID:WellingR,项目名称:Maximal-Common-Subgraph,代码行数:18,代码来源:Algorithm3.java

示例3: neighbour_C_Vertices

import org.jgrapht.graph.SimpleGraph; //导入方法依赖的package包/类
/**
 * return only the vertices that neighbour u with C_Edges
 * @param u a Vertex of g
 * @return {v ELEMENTOF V | {u,v} ELEMENTOF E}
 */
private static <V> Set<V> neighbour_C_Vertices(SimpleGraph<V,CompatibilityEdge> g, V u){
	Set<V> result = new LinkedHashSet<V>();
	for(CompatibilityEdge edge : g.edgesOf(u)){
        if(edge.isC_Edge()){
 		V neighbour = g.getEdgeSource(edge);
         if(neighbour.equals(u)){
             neighbour = g.getEdgeTarget(edge);
         }
         result.add(neighbour);
        }
    }
	return result;
}
 
开发者ID:WellingR,项目名称:Maximal-Common-Subgraph,代码行数:19,代码来源:Algorithm5.java

示例4: enumerateCliques

import org.jgrapht.graph.SimpleGraph; //导入方法依赖的package包/类
/**
 * 
 * @param g The graph where the largest clique needs to be found
 * @param c Set of vertices belonging to the current clique
 * @param p Set of vertices which can be added to C
 * @param s set of vertices which are not allowed to be added to C
 * @return the largest clique in graph g
 */
private static <V,E> Set<V> enumerateCliques(SimpleGraph<V,E> g, Set<V> c, Set<V> p, int currentmaxresult){
    Set<V> result = new LinkedHashSet<V>(c);
    if(p.isEmpty() || p.size() + c.size() <= currentmaxresult){   //if p=EMPTY and s=EMPTY
    	//check for s.isEmpty is removed because the code will return the same result if only P is empty
        return result;                               //REPORT.CLIQUE
    } else {
        Set<V> pCopy = new LinkedHashSet<V>(p);
        for(V currentVertex : p){                    //for i <- 1 to k
            pCopy.remove(currentVertex);             //P <-P\{ui}
            Set<V> pNext = new LinkedHashSet<V>(pCopy);    //P' <- P
            Set<V> n = new LinkedHashSet<V>();             
            for(E edge : g.edgesOf(currentVertex)){
                V neighbour = g.getEdgeSource(edge);
                if(neighbour.equals(currentVertex)){
                    neighbour = g.getEdgeTarget(edge);
                }
                n.add(neighbour);
            }                                        //N <- { v ELEMENTOF V | {ui,v} ELEMENTOF E }

            Set<V> cNext = new LinkedHashSet<V>(c);
            cNext.add(currentVertex);                //C UNION {ui}
            pNext.retainAll(n);                      //P' INTERSECTION N
            
            Set<V> clique = enumerateCliques(g, cNext, pNext, currentmaxresult); //ENUMERATE.CLIQUES....
            if(clique.size() > result.size()){
                result = clique;
                currentmaxresult = clique.size();
            }
        }
    }
    return result;
}
 
开发者ID:WellingR,项目名称:Maximal-Common-Subgraph,代码行数:41,代码来源:Algorithm1.java


注:本文中的org.jgrapht.graph.SimpleGraph.getEdgeSource方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。