本文整理汇总了Java中edu.uci.ics.jung.graph.Hypergraph.getIncidentEdges方法的典型用法代码示例。如果您正苦于以下问题:Java Hypergraph.getIncidentEdges方法的具体用法?Java Hypergraph.getIncidentEdges怎么用?Java Hypergraph.getIncidentEdges使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edu.uci.ics.jung.graph.Hypergraph
的用法示例。
在下文中一共展示了Hypergraph.getIncidentEdges方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: foldHypergraphVertices
import edu.uci.ics.jung.graph.Hypergraph; //导入方法依赖的package包/类
/**
* Creates a <code>Graph</code> which is a vertex-folded version of <code>h</code>, whose
* vertices are the input's hyperedges and whose edges are induced by adjacent hyperedges
* in the input.
*
* <p>The vertices of the new graph are the same objects as the hyperedges of
* <code>h</code>, and <code>a</code>
* is connected to <code>b</code> in the new graph if the corresponding edges
* in <code>h</code> have a vertex in common. Thus, each vertex incident to
* <i>k</i> edges in <code>h</code> induces a <i>k</i>-clique in the new graph.</p>
*
* <p>The edges of the new graph are created by the specified factory.</p>
*
* @param <V> vertex type
* @param <E> input edge type
* @param <F> output edge type
* @param h hypergraph to be folded
* @param graph_factory factory used to generate the output graph
* @param edge_factory factory used to generate the output edges
* @return a transformation of the input graph whose vertices correspond to the input's hyperedges
* and edges are induced by hyperedges sharing vertices in the input
*/
public static <V,E,F> Graph<E,F> foldHypergraphVertices(Hypergraph<V,E> h,
Factory<Graph<E,F>> graph_factory, Factory<F> edge_factory)
{
Graph<E,F> target = graph_factory.create();
for (E e : h.getEdges())
target.addVertex(e);
for (V v : h.getVertices())
{
ArrayList<E> incident = new ArrayList<E>(h.getIncidentEdges(v));
for (int i = 0; i < incident.size(); i++)
for (int j = i+1; j < incident.size(); j++)
target.addEdge(edge_factory.create(), incident.get(i), incident.get(j));
}
return target;
}