本文整理汇总了Java中org.jgrapht.graph.DirectedWeightedMultigraph类的典型用法代码示例。如果您正苦于以下问题:Java DirectedWeightedMultigraph类的具体用法?Java DirectedWeightedMultigraph怎么用?Java DirectedWeightedMultigraph使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DirectedWeightedMultigraph类属于org.jgrapht.graph包,在下文中一共展示了DirectedWeightedMultigraph类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: addGraph
import org.jgrapht.graph.DirectedWeightedMultigraph; //导入依赖的package包/类
public static DirectedWeightedMultigraph<Long, RelationshipEdge> addGraph(
DefaultDirectedWeightedGraph<Long, DefaultWeightedEdge> g, String label,
DirectedWeightedMultigraph<Long, RelationshipEdge> graph) {
System.out.println("Add Graph");
for (Long vertex : g.vertexSet()) {
graph.addVertex(vertex);
}
for (DefaultWeightedEdge e : g.edgeSet()) {
graph.addEdge(g.getEdgeSource(e), g.getEdgeTarget(e),
new RelationshipEdge<Long>(g.getEdgeSource(e), g.getEdgeTarget(e), label));
RelationshipEdge<Long> edge = graph.getEdge(g.getEdgeSource(e), g.getEdgeTarget(e));
graph.setEdgeWeight(edge, g.getEdgeWeight(e));
System.out.println("Edge added");
}
return graph;
}
开发者ID:IGNF,项目名称:geoxygene,代码行数:17,代码来源:LabeledEdges.java
示例2: getGraphFromLinkMap
import org.jgrapht.graph.DirectedWeightedMultigraph; //导入依赖的package包/类
/** <p>Obtains a {@code JGraphT} graph from a given link map.</p>
*
* @param nodes Collection of nodes
* @param links List of links
* @return {@code JGraphT} graph */
public static org.jgrapht.Graph<Node, Link> getGraphFromLinkMap(Collection<Node> nodes, Collection<Link> links)
{
org.jgrapht.Graph<Node, Link> graph = new DirectedWeightedMultigraph<Node, Link>(Link.class);
for (Node node : nodes)
graph.addVertex(node);
if (links != null)
{
for (Link link : links)
{
Node originNode = link.getOriginNode();
Node destinationNode = link.getDestinationNode();
if (!graph.containsVertex(originNode)) throw new RuntimeException("Bad"); //graph.addVertex(originNode);
if (!graph.containsVertex(destinationNode)) throw new RuntimeException("Bad"); //graph.addVertex(destinationNode);
graph.addEdge(originNode, destinationNode, link);
}
}
return graph;
}
开发者ID:girtel,项目名称:Net2Plan,代码行数:29,代码来源:GraphUtils.java
示例3: getGraphFromDemandMap
import org.jgrapht.graph.DirectedWeightedMultigraph; //导入依赖的package包/类
/** <p>Obtains a {@code JGraphT} graph from a given link map.</p>
*
* @param demands List of demands
* @return {@code JGraphT} graph */
public static org.jgrapht.Graph<Node, Demand> getGraphFromDemandMap(List<Demand> demands)
{
org.jgrapht.Graph<Node, Demand> graph = new DirectedWeightedMultigraph<Node, Demand>(Demand.class);
if (demands != null)
{
for (Demand demand : demands)
{
Node originNode = demand.getIngressNode();
Node destinationNode = demand.getEgressNode();
if (!graph.containsVertex(originNode)) graph.addVertex(originNode);
if (!graph.containsVertex(destinationNode)) graph.addVertex(destinationNode);
graph.addEdge(originNode, destinationNode, demand);
}
}
return graph;
}
开发者ID:girtel,项目名称:Net2Plan,代码行数:25,代码来源:GraphUtils.java
示例4: getGraphFromRouteMap
import org.jgrapht.graph.DirectedWeightedMultigraph; //导入依赖的package包/类
/** <p>Obtains a {@code JGraphT} graph from a given route map.</p>
*
* @param demands List of demands
* @return {@code JGraphT} graph */
public static org.jgrapht.Graph<Node, Route> getGraphFromRouteMap(List<Route> routes)
{
org.jgrapht.Graph<Node, Route> graph = new DirectedWeightedMultigraph<Node, Route>(Route.class);
if (routes != null)
{
for (Route route : routes)
{
Node originNode = route.getIngressNode();
Node destinationNode = route.getEgressNode();
if (!graph.containsVertex(originNode)) graph.addVertex(originNode);
if (!graph.containsVertex(destinationNode)) graph.addVertex(destinationNode);
graph.addEdge(originNode, destinationNode, route);
}
}
return graph;
}
开发者ID:girtel,项目名称:Net2Plan,代码行数:24,代码来源:GraphUtils.java
示例5: doIt
import org.jgrapht.graph.DirectedWeightedMultigraph; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public UpdateContainer doIt(Workspace workspace) throws CommandException {
logCommand(logger, workspace);
Alignment alignment = AlignmentManager.Instance().getAlignment(
alignmentId);
// Save the original alignment for undo
oldAlignment = alignment.getAlignmentClone();
oldGraph = (DirectedWeightedMultigraph<Node, DefaultLink>) alignment
.getGraph().clone();
try {
alignment.addForcedInternalNode(new Label(nodeUri));
if(!this.isExecutedInBatch())
alignment.align();
} catch (JSONException e) {
logger.error("Error adding Internal Node:" , e);
}
return WorksheetUpdateFactory.createSemanticTypesAndSVGAlignmentUpdates(worksheetId, workspace);
}
开发者ID:therelaxist,项目名称:spring-usc,代码行数:25,代码来源:AddNodeCommand.java
示例6: doIt
import org.jgrapht.graph.DirectedWeightedMultigraph; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public UpdateContainer doIt(Workspace workspace) throws CommandException {
logCommand(logger, workspace);
Alignment alignment = AlignmentManager.Instance().getAlignment(
alignmentId);
// Save the original alignment for undo
oldAlignment = alignment.getAlignmentClone();
oldGraph = (DirectedWeightedMultigraph<Node, DefaultLink>) alignment
.getGraph().clone();
try {
alignment.deleteForcedInternalNode(nodeId);
if(!this.isExecutedInBatch())
alignment.align();
} catch (JSONException e) {
logger.error("Error adding Internal Node:" , e);
}
return WorksheetUpdateFactory.createSemanticTypesAndSVGAlignmentUpdates(worksheetId, workspace);
}
开发者ID:therelaxist,项目名称:spring-usc,代码行数:24,代码来源:DeleteNodeCommand.java
示例7: SemanticModel
import org.jgrapht.graph.DirectedWeightedMultigraph; //导入依赖的package包/类
public SemanticModel(Workspace workspace, Worksheet worksheet,
String id,
DirectedWeightedMultigraph<Node, LabeledLink> graph,
SuperSelection sel) {
this.workspace = workspace;
this.worksheet = worksheet;
this.id = id;
this.graph = graph;
this.selection = sel;
this.setLearnedTypesForColumnNodes();
this.setUserTypesForColumnNodes();
this.sourceColumns = this.getColumnNodes();
this.mappingToSourceColumns = new HashMap<ColumnNode, ColumnNode>();
for (ColumnNode c : this.sourceColumns)
this.mappingToSourceColumns.put(c, c);
}
开发者ID:therelaxist,项目名称:spring-usc,代码行数:18,代码来源:SemanticModel.java
示例8: getTriples
import org.jgrapht.graph.DirectedWeightedMultigraph; //导入依赖的package包/类
private Set<String> getTriples(DirectedWeightedMultigraph<Node, LabeledLink> g, HashMap<Node,String> nodeIds) {
String separator = "|";
Set<String> triples = new HashSet<String>();
if (g == null)
return triples;
String s, p, o, triple;
for (LabeledLink l : g.edgeSet()) {
// FIXME: this line skips the links corresponding to the semantic types
// if (!(l.getTarget() instanceof InternalNode))
// continue;
s = nodeIds.get(l.getSource());
o = nodeIds.get(l.getTarget());
p = l.getLabel().getUri();
triple = s + separator + p + separator + o;
// System.out.println(triple);
triples.add(triple);
}
return triples;
}
开发者ID:therelaxist,项目名称:spring-usc,代码行数:23,代码来源:SemanticModel.java
示例9: asDirectedGraph
import org.jgrapht.graph.DirectedWeightedMultigraph; //导入依赖的package包/类
public static DirectedGraph<Node, DefaultLink> asDirectedGraph(UndirectedGraph<Node, DefaultLink> undirectedGraph) {
if (undirectedGraph == null) {
logger.debug("graph is null.");
return null;
}
DirectedGraph<Node, DefaultLink> g = new DirectedWeightedMultigraph<Node, DefaultLink>(DefaultLink.class);
for (Node v : undirectedGraph.vertexSet())
g.addVertex(v);
for (DefaultLink e: undirectedGraph.edgeSet())
g.addEdge(e.getSource(), e.getTarget(), e);
return g;
}
开发者ID:therelaxist,项目名称:spring-usc,代码行数:18,代码来源:GraphUtil.java
示例10: asDefaultGraph
import org.jgrapht.graph.DirectedWeightedMultigraph; //导入依赖的package包/类
public static DirectedWeightedMultigraph<Node, DefaultLink> asDefaultGraph(DirectedWeightedMultigraph<Node, LabeledLink> graph) {
if (graph == null) {
logger.debug("graph is null.");
return null;
}
DirectedWeightedMultigraph<Node, DefaultLink> g = new DirectedWeightedMultigraph<Node, DefaultLink>(DefaultLink.class);
for (Node v : graph.vertexSet())
g.addVertex(v);
for (DefaultLink e: graph.edgeSet())
g.addEdge(e.getSource(), e.getTarget(), e);
return g;
}
开发者ID:therelaxist,项目名称:spring-usc,代码行数:18,代码来源:GraphUtil.java
示例11: asLabeledGraph
import org.jgrapht.graph.DirectedWeightedMultigraph; //导入依赖的package包/类
public static DirectedWeightedMultigraph<Node, LabeledLink> asLabeledGraph(DirectedWeightedMultigraph<Node, DefaultLink> graph) {
if (graph == null) {
logger.debug("graph is null.");
return null;
}
DirectedWeightedMultigraph<Node, LabeledLink> g = new DirectedWeightedMultigraph<Node, LabeledLink>(LabeledLink.class);
for (Node v : graph.vertexSet())
g.addVertex(v);
for (DefaultLink e: graph.edgeSet())
if (e instanceof LabeledLink)
g.addEdge(e.getSource(), e.getTarget(), (LabeledLink)e);
return g;
}
开发者ID:therelaxist,项目名称:spring-usc,代码行数:19,代码来源:GraphUtil.java
示例12: exportJson
import org.jgrapht.graph.DirectedWeightedMultigraph; //导入依赖的package包/类
public static void exportJson(DirectedWeightedMultigraph<Node, DefaultLink> graph, String filename) throws IOException {
logger.info("exporting the graph to json ...");
File file = new File(filename);
if (!file.exists()) {
file.createNewFile();
}
FileOutputStream out = new FileOutputStream(file);
JsonWriter writer = new JsonWriter(new OutputStreamWriter(out, "UTF-8"));
//writer.setIndent(" ");
try {
writeGraph(graph, writer);
// writeGraph(workspace, worksheet, graph, writer);
} catch (Exception e) {
logger.error("error in writing the model in json!");
e.printStackTrace();
} finally {
writer.close();
}
logger.info("export is done.");
}
开发者ID:therelaxist,项目名称:spring-usc,代码行数:22,代码来源:GraphUtil.java
示例13: importJson
import org.jgrapht.graph.DirectedWeightedMultigraph; //导入依赖的package包/类
public static DirectedWeightedMultigraph<Node, DefaultLink> importJson(String filename) throws IOException {
File file = new File(filename);
if (!file.exists()) {
logger.error("cannot open the file " + filename);
}
FileInputStream in = new FileInputStream(file);
JsonReader reader = new JsonReader(new InputStreamReader(in, "UTF-8"));
try {
return readGraph(reader);
} catch (Exception e) {
logger.error("error in reading the model from json!");
e.printStackTrace();
return null;
} finally {
reader.close();
}
}
开发者ID:therelaxist,项目名称:spring-usc,代码行数:20,代码来源:GraphUtil.java
示例14: writeGraph
import org.jgrapht.graph.DirectedWeightedMultigraph; //导入依赖的package包/类
public static void writeGraph(DirectedWeightedMultigraph<Node, DefaultLink> graph, JsonWriter writer) throws IOException {
writer.beginObject();
writer.name("nodes");
writer.beginArray();
if (graph != null)
for (Node n : graph.vertexSet())
writeNode(writer, n);
// writeNode(workspace, worksheet, writer, n);
writer.endArray();
writer.name("links");
writer.beginArray();
if (graph != null)
for (DefaultLink l : graph.edgeSet())
writeLink(writer, l);
writer.endArray();
writer.endObject();
}
开发者ID:therelaxist,项目名称:spring-usc,代码行数:23,代码来源:GraphUtil.java
示例15: ModelLearningGraph
import org.jgrapht.graph.DirectedWeightedMultigraph; //导入依赖的package包/类
protected ModelLearningGraph(OntologyManager ontologyManager, ModelLearningGraphType type) throws IOException {
this.ontologyManager = ontologyManager;
File file = new File(getGraphJsonName());
if (!file.exists()) {
this.initializeFromJsonRepository();
} else {
logger.info("loading the alignment graph ...");
DirectedWeightedMultigraph<Node, DefaultLink> graph =
GraphUtil.importJson(getGraphJsonName());
if (type == ModelLearningGraphType.Compact)
this.graphBuilder = new GraphBuilderTopK(ontologyManager, graph);
else
this.graphBuilder = new GraphBuilder(ontologyManager, graph, false);
this.nodeIdFactory = this.graphBuilder.getNodeIdFactory();
logger.info("loading is done!");
}
if (this.graphBuilder.getGraph() != null) {
logger.info("number of nodes: " + this.graphBuilder.getGraph().vertexSet().size());
logger.info("number of links: " + this.graphBuilder.getGraph().edgeSet().size());
}
this.lastUpdateTime = System.currentTimeMillis();
}
开发者ID:therelaxist,项目名称:spring-usc,代码行数:25,代码来源:ModelLearningGraph.java
示例16: exportJGraphToGraphviz
import org.jgrapht.graph.DirectedWeightedMultigraph; //导入依赖的package包/类
public static void exportJGraphToGraphviz(
DirectedWeightedMultigraph<Node, DefaultLink> graph,
String label,
boolean onlyAddPatterns,
GraphVizLabelType nodeLabelType,
GraphVizLabelType linkLabelType,
boolean showNodeMetaData,
boolean showLinkMetaData,
String filename) throws IOException {
logger.info("exporting the graph to graphviz ...");
org.kohsuke.graphviz.Graph graphViz =
convertToGraphviz(graph, null, onlyAddPatterns, nodeLabelType, linkLabelType, showNodeMetaData, showLinkMetaData);;
graphViz.attr("fontcolor", "blue");
graphViz.attr("remincross", "true");
graphViz.attr("label", label == null ? "" : label);
OutputStream out = new FileOutputStream(filename);
graphViz.writeTo(out);
logger.info("export is done.");
}
开发者ID:therelaxist,项目名称:spring-usc,代码行数:24,代码来源:GraphVizUtil.java
示例17: inDegreeInSet
import org.jgrapht.graph.DirectedWeightedMultigraph; //导入依赖的package包/类
private static HashMap<Node, Integer> inDegreeInSet(DirectedWeightedMultigraph<Node, LabeledLink> g,
Set<Node> nodes, boolean includeSelfLinks) {
HashMap<Node, Integer> nodeToInDegree = new HashMap<Node, Integer>();
if (g == null || nodes == null) return nodeToInDegree;
for (Node n : nodes) {
Set<LabeledLink> incomingLinks = g.incomingEdgesOf(n);
if (incomingLinks == null || incomingLinks.size() == 0) {
nodeToInDegree.put(n, 0);
} else {
int count = 0;
for (LabeledLink l : incomingLinks) {
if (includeSelfLinks) {
if (nodes.contains(l.getSource())) count++;
} else {
if (nodes.contains(l.getSource()) && !n.equals(l.getSource())) count++;
}
}
nodeToInDegree.put(n, count);
}
}
return nodeToInDegree;
}
开发者ID:therelaxist,项目名称:spring-usc,代码行数:24,代码来源:DisplayModel.java
示例18: outDegreeInSet
import org.jgrapht.graph.DirectedWeightedMultigraph; //导入依赖的package包/类
private static HashMap<Node, Integer> outDegreeInSet(DirectedWeightedMultigraph<Node, LabeledLink> g,
Set<Node> nodes, boolean includeSelfLinks) {
HashMap<Node, Integer> nodeToOutDegree = new HashMap<Node, Integer>();
if (g == null || nodes == null) return nodeToOutDegree;
for (Node n : nodes) {
Set<LabeledLink> outgoingLinks = g.outgoingEdgesOf(n);
if (outgoingLinks == null || outgoingLinks.size() == 0) {
nodeToOutDegree.put(n, 0);
} else {
int count = 0;
for (LabeledLink l : outgoingLinks) {
if (includeSelfLinks) {
if (nodes.contains(l.getSource())) count++;
} else {
if (nodes.contains(l.getSource()) && !n.equals(l.getSource())) count++;
}
}
nodeToOutDegree.put(n, count);
}
}
return nodeToOutDegree;
}
开发者ID:therelaxist,项目名称:spring-usc,代码行数:24,代码来源:DisplayModel.java
示例19: cycleExits
import org.jgrapht.graph.DirectedWeightedMultigraph; //导入依赖的package包/类
private boolean cycleExits(DirectedWeightedMultigraph<Node, LabeledLink> model, Set<Node> columnNodes, Set<Node> traversedNodes, Node start, Node end) {
Set<Node> neighbors = GraphUtil.getOutNeighbors(GraphUtil.asDefaultGraph(model), start);
logger.debug("start:" + start.getDisplayId() + ", end:" + end.getDisplayId());
for (Node w : neighbors) {
if(w == end) {
return true;
}
if(columnNodes.contains(w) || traversedNodes.contains(w))
continue;
traversedNodes.add(w);
logger.debug("neighbour:" + w.getDisplayId());
boolean innerCycle = cycleExits(model, columnNodes, traversedNodes, w, end);
if(innerCycle)
return true;
}
return false;
}
开发者ID:therelaxist,项目名称:spring-usc,代码行数:19,代码来源:DisplayModel.java
示例20: addOntologyPaths
import org.jgrapht.graph.DirectedWeightedMultigraph; //导入依赖的package包/类
public GraphBuilder addOntologyPaths(DirectedWeightedMultigraph<Node, LabeledLink> graph) {
logger.info("graph nodes before using ontology: " + graph.vertexSet().size());
logger.info("graph links before using ontology: " + graph.edgeSet().size());
GraphBuilder graphBuilder = new GraphBuilder(ontologyManager, false);
for (Node n : graph.vertexSet()) {
graphBuilder.addNodeAndUpdate(n);
}
for (DefaultLink l : graph.edgeSet()) {
graphBuilder.addLink(l.getSource(), l.getTarget(), l, l.getWeight());
}
logger.info("graph nodes after using ontology: " + graphBuilder.getGraph().vertexSet().size());
logger.info("graph links after using ontology: " + graphBuilder.getGraph().edgeSet().size());
return graphBuilder;
}
开发者ID:therelaxist,项目名称:spring-usc,代码行数:19,代码来源:ModelLearner_LOD_Greedy.java
注:本文中的org.jgrapht.graph.DirectedWeightedMultigraph类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论