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