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


Java Hypergraph.getIncidentEdges方法代码示例

本文整理汇总了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;
}
 
开发者ID:SiLeBAT,项目名称:BfROpenLab,代码行数:41,代码来源:FoldingTransformer.java


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