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


Java Hypergraph.getVertices方法代码示例

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


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

示例1: initialize

import edu.uci.ics.jung.graph.Hypergraph; //导入方法依赖的package包/类
protected void initialize(Hypergraph<V,E> g, Set<V> rootSet) {
    mVerticesInOrderVisited = new ArrayList<V>();
    mUnvisitedVertices = new HashSet<V>();
    for(V currentVertex : g.getVertices()) {
        mUnvisitedVertices.add(currentVertex);
        mPredecessorMap.put(currentVertex,new HashSet<V>());
    }

    mCurrentList = new ArrayList<V>();
    for(V v : rootSet) {
        distanceDecorator.put(v, new Integer(0));
        mCurrentList.add(v);
        mUnvisitedVertices.remove(v);
        mVerticesInOrderVisited.add(v);
    }
}
 
开发者ID:SiLeBAT,项目名称:BfROpenLab,代码行数:17,代码来源:BFSDistanceLabeler.java

示例2: writeVertexData

import edu.uci.ics.jung.graph.Hypergraph; //导入方法依赖的package包/类
protected void writeVertexData(Hypergraph<V,E> graph, BufferedWriter w) throws IOException
{
	for (V v: graph.getVertices())
	{
		String v_string = String.format("<node id=\"%s\"", vertex_ids.transform(v));
		boolean closed = false;
		// write description out if any
		String desc = vertex_desc.transform(v);
		if (desc != null)
		{
			w.write(v_string + ">\n");
			closed = true;
			w.write("<desc>" + desc + "</desc>\n");
		}
		// write data out if any
		for (String key : vertex_data.keySet())
		{
			Transformer<V, ?> t = vertex_data.get(key).transformer;
			if (t != null)
			{
   				Object value = t.transform(v);
   				if (value != null)
   				{
   					if (!closed)
   					{
   						w.write(v_string + ">\n");
   						closed = true;
   					}
   					w.write(format("data", "key", key, StringEscapeUtils.escapeXml(value.toString())) + "\n");
   				}
			}
		}
		if (!closed)
			w.write(v_string + "/>\n"); // no contents; close the node with "/>"
		else
		    w.write("</node>\n");
	}
}
 
开发者ID:iTransformers,项目名称:netTransformer,代码行数:39,代码来源:MyGraphMLWriter.java

示例3: writeVertexData

import edu.uci.ics.jung.graph.Hypergraph; //导入方法依赖的package包/类
protected void writeVertexData(Hypergraph<V,E> graph, BufferedWriter w) throws IOException
{
	for (V v: graph.getVertices())
	{
		String v_string = String.format("<node id=\"%s\"", vertex_ids.transform(v));
		boolean closed = false;
		// write description out if any
		String desc = vertex_desc.transform(v);
		if (desc != null)
		{
			w.write(v_string + ">\n");
			closed = true;
			w.write("<desc>" + desc + "</desc>\n");
		}
		// write data out if any
		for (String key : vertex_data.keySet())
		{
			Transformer<V, ?> t = vertex_data.get(key).transformer;
			if (t != null)
			{
   				Object value = t.transform(v);
   				if (value != null)
   				{
   					if (!closed)
   					{
   						w.write(v_string + ">\n");
   						closed = true;
   					}
   					w.write(format("data", "key", key, value.toString()) + "\n");
   				}
			}
		}
		if (!closed)
			w.write(v_string + "/>\n"); // no contents; close the node with "/>"
		else
		    w.write("</node>\n");
	}
}
 
开发者ID:SiLeBAT,项目名称:BfROpenLab,代码行数:39,代码来源:GraphMLWriter.java

示例4: foldHypergraphEdges

import edu.uci.ics.jung.graph.Hypergraph; //导入方法依赖的package包/类
/**
 * Creates a <code>Graph</code> which is an edge-folded version of <code>h</code>, where
 * hyperedges are replaced by k-cliques in the output graph.
 * 
 * <p>The vertices of the new graph are the same objects as the vertices of 
 * <code>h</code>, and <code>a</code> 
 * is connected to <code>b</code> in the new graph if the corresponding vertices
 * in <code>h</code> are connected by a hyperedge.  Thus, each hyperedge with 
 * <i>k</i> vertices in <code>h</code> induces a <i>k</i>-clique in the new graph.</p>
 * 
 * <p>The edges of the new graph consist of collections of each hyperedge that connected
 * the corresponding vertex pair in the original graph.</p>
 * 
 * @param <V> vertex type
 * @param <E> input edge type
 * @param h hypergraph to be folded
 * @param graph_factory factory used to generate the output graph
 * @return a copy of the input graph where hyperedges are replaced by cliques
 */
public static <V,E> Graph<V, Collection<E>> foldHypergraphEdges(Hypergraph<V,E> h, 
        Factory<Graph<V, Collection<E>>> graph_factory)
{
    Graph<V, Collection<E>> target = graph_factory.create();

    for (V v : h.getVertices())
        target.addVertex(v);
    
    for (E e : h.getEdges())
    {
        ArrayList<V> incident = new ArrayList<V>(h.getIncidentVertices(e));
        populateTarget(target, e, incident);
    }
    return target;
}
 
开发者ID:SiLeBAT,项目名称:BfROpenLab,代码行数:35,代码来源:FoldingTransformer.java

示例5: 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

示例6: fold

import edu.uci.ics.jung.graph.Hypergraph; //导入方法依赖的package包/类
/**
 * Creates a <code>Graph</code> which is a "folded" version of <code>h</code>.
 * 
 * <p>If <code>use_vertices</code> is true, the vertices of the new graph 
 * correspond to the vertices of <code>h</code>, and <code>a</code> 
 * is connected to <code>b</code> in the new graph if the corresponding vertices
 * in <code>h</code> are connected by a hyperedge.  Thus, each hyperedge with 
 * <i>k</i> vertices in <code>h</code> would induce a <i>k</i>-clique in the new graph.</p>
 * 
 * <p>If <code>use_vertices</code> is false, then the vertices of the new
 * graph correspond to the hyperedges of <code>h</code>, and <code>a</code>
 * is connected to <code>b</code> in the new graph if the corresponding hyperedges
 * in <code>h</code> share a vertex.  Thus, each vertex connected to <i>k</i> 
 * hyperedges in <code>h</code> would induce a <i>k</i>-clique in the new graph.</p>
 * 
 * <p>If <code>nev</code> is null, 
 * adds the connecting element as a decoration on the corresponding edge in the new
 * graph; otherwise, sets the weight of each edge to the number of parallel 
 * paths between the corresponding vertices in the original graph that are 
 * encountered in the folding process.</p>
 */
public Graph fold(Hypergraph h, Graph target, boolean use_vertices, NumberEdgeValue nev, BidiMap map)
{
    undirected = true;
    
    if (target == null)
        target = createGraph();

    VertexGenerator vg = GraphUtils.getVertexGenerator(target);
    if (vg == null)
        vg = new TypedVertexGenerator(target);
    
    Map m = new HashMap();
    Set vertices;
    Set edges;
    
    // vertices and hyperedges are duals of one another; we can treat
    // them equivalently for this purpose
    if (use_vertices)
    {
        vertices = h.getVertices();
        edges = h.getEdges();
    }
    else
    {
        vertices = h.getEdges();
        edges = h.getVertices();
    }
    
    // create vertices:
    // for each "vertex", create a new vertex and import user data
    for (Iterator iter = vertices.iterator(); iter.hasNext(); )
    {
        Element av = (Element)iter.next();
        Vertex v = vg.create();
        v.importUserData(av);
        target.addVertex(v);
        m.put(av, v);
        map.put(v, av);
    }
    
    // create edges:
    // for each "hyperedge", create an edge between each incident vertex pair
    for (Iterator iter = edges.iterator(); iter.hasNext(); )
    {
        Element he = (Element)iter.next();
        Set elts = he.getIncidentElements();
        Vertex[] v_array = new Vertex[elts.size()];
        int i = 0;
        for (Iterator e_iter = elts.iterator(); e_iter.hasNext(); )
            v_array[i++] = (Vertex)(m.get(e_iter.next()));
        for (i = 0; i < v_array.length; i++)
            for (int j = i + 1; j < v_array.length; j++)
                addEdge(target, v_array[i], he, v_array[j], nev);
    }
    
    return target;
}
 
开发者ID:markus1978,项目名称:clickwatch,代码行数:79,代码来源:FoldingTransformer.java


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