本文整理汇总了Java中edu.uci.ics.jung.graph.Hypergraph.getIncidentVertices方法的典型用法代码示例。如果您正苦于以下问题:Java Hypergraph.getIncidentVertices方法的具体用法?Java Hypergraph.getIncidentVertices怎么用?Java Hypergraph.getIncidentVertices使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edu.uci.ics.jung.graph.Hypergraph
的用法示例。
在下文中一共展示了Hypergraph.getIncidentVertices方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writeEdgeData
import edu.uci.ics.jung.graph.Hypergraph; //导入方法依赖的package包/类
protected void writeEdgeData(Hypergraph<V,E> g, Writer w) throws IOException
{
for (E e: g.getEdges())
{
Collection<V> vertices = g.getIncidentVertices(e);
String id = edge_ids.transform(e);
String e_string;
boolean is_hyperedge = !(g instanceof Graph);
if (is_hyperedge)
{
e_string = "<hyperedge ";
// add ID if present
if (id != null)
e_string += "id=\"" + id + "\" ";
}
else
{
Pair<V> endpoints = new Pair<V>(vertices);
V v1 = endpoints.getFirst();
V v2 = endpoints.getSecond();
e_string = "<edge ";
// add ID if present
if (id != null)
e_string += "id=\"" + id + "\" ";
// add edge type if doesn't match default
EdgeType edge_type = g.getEdgeType(e);
if (directed && edge_type == EdgeType.UNDIRECTED)
e_string += "directed=\"false\" ";
if (!directed && edge_type == EdgeType.DIRECTED)
e_string += "directed=\"true\" ";
e_string += "source=\"" + vertex_ids.transform(v1) +
"\" target=\"" + vertex_ids.transform(v2) + "\"";
}
boolean closed = false;
// write description out if any
String desc = edge_desc.transform(e);
if (desc != null)
{
w.write(e_string + ">\n");
closed = true;
w.write("<desc>" + desc + "</desc>\n");
}
// write data out if any
for (String key : edge_data.keySet())
{
Transformer<E, ?> t = edge_data.get(key).transformer;
Object value = t.transform(e);
if (value != null)
{
if (!closed)
{
w.write(e_string + ">\n");
closed = true;
}
w.write(format("data", "key", key, StringEscapeUtils.escapeXml(value.toString())) + "\n");
}
}
// if this is a hyperedge, write endpoints out if any
if (is_hyperedge)
{
for (V v : vertices)
{
if (!closed)
{
w.write(e_string + ">\n");
closed = true;
}
w.write("<endpoint node=\"" + vertex_ids.transform(v) + "\"/>\n");
}
}
if (!closed)
w.write(e_string + "/>\n"); // no contents; close the edge with "/>"
else
if (is_hyperedge)
w.write("</hyperedge>\n");
else
w.write("</edge>\n");
}
}
示例2: 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;
}
示例3: writeEdgeData
import edu.uci.ics.jung.graph.Hypergraph; //导入方法依赖的package包/类
protected void writeEdgeData(Hypergraph<V,E> g, Writer w) throws IOException
{
for (E e: g.getEdges())
{
Collection<V> vertices = g.getIncidentVertices(e);
String id = edge_ids.transform(e);
String e_string;
boolean is_hyperedge = !(g instanceof Graph);
if (is_hyperedge)
{
e_string = "<hyperedge ";
// add ID if present
if (id != null)
e_string += "id=\"" + id + "\" ";
}
else
{
Pair<V> endpoints = new Pair<V>(vertices);
V v1 = endpoints.getFirst();
V v2 = endpoints.getSecond();
e_string = "<edge ";
// add ID if present
if (id != null)
e_string += "id=\"" + id + "\" ";
// add edge type if doesn't match default
EdgeType edge_type = g.getEdgeType(e);
if (directed && edge_type == EdgeType.UNDIRECTED)
e_string += "directed=\"false\" ";
if (!directed && edge_type == EdgeType.DIRECTED)
e_string += "directed=\"true\" ";
e_string += "source=\"" + vertex_ids.transform(v1) +
"\" target=\"" + vertex_ids.transform(v2) + "\"";
}
boolean closed = false;
// write description out if any
String desc = edge_desc.transform(e);
if (desc != null)
{
w.write(e_string + ">\n");
closed = true;
w.write("<desc>" + desc + "</desc>\n");
}
// write data out if any
for (String key : edge_data.keySet())
{
Transformer<E, ?> t = edge_data.get(key).transformer;
Object value = t.transform(e);
if (value != null)
{
if (!closed)
{
w.write(e_string + ">\n");
closed = true;
}
w.write(format("data", "key", key, value.toString()) + "\n");
}
}
// if this is a hyperedge, write endpoints out if any
if (is_hyperedge)
{
for (V v : vertices)
{
if (!closed)
{
w.write(e_string + ">\n");
closed = true;
}
w.write("<endpoint node=\"" + vertex_ids.transform(v) + "\"/>\n");
}
}
if (!closed)
w.write(e_string + "/>\n"); // no contents; close the edge with "/>"
else
if (is_hyperedge)
w.write("</hyperedge>\n");
else
w.write("</edge>\n");
}
}