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


Java DirectedPseudograph类代码示例

本文整理汇总了Java中org.jgrapht.graph.DirectedPseudograph的典型用法代码示例。如果您正苦于以下问题:Java DirectedPseudograph类的具体用法?Java DirectedPseudograph怎么用?Java DirectedPseudograph使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: extractMentionNetwork

import org.jgrapht.graph.DirectedPseudograph; //导入依赖的package包/类
protected DirectedGraph<Figure, DefaultEdge> extractMentionNetwork(JCas jcas) {
	DirectedGraph<Figure, DefaultEdge> graph = new DirectedPseudograph<Figure, DefaultEdge>(DefaultEdge.class);

	for (Utterance utterance : JCasUtil.select(jcas, Utterance.class)) {
		Speaker speaker = DramaUtil.getFirstSpeaker(utterance);
		if (speaker != null)
			for (FigureMention mention : JCasUtil.selectCovered(jcas, FigureMention.class, utterance)) {
				if (speaker.getFigure() != null && mention.getFigure() != null) {
					if (!graph.containsVertex(speaker.getFigure()))
						graph.addVertex(speaker.getFigure());
					if (!graph.containsVertex(mention.getFigure()))
						graph.addVertex(mention.getFigure());
					graph.addEdge(speaker.getFigure(), mention.getFigure());
				}
			}
	}
	return graph;
}
 
开发者ID:quadrama,项目名称:DramaNLP,代码行数:19,代码来源:NetworkExtractor.java

示例2: checkIsDAG

import org.jgrapht.graph.DirectedPseudograph; //导入依赖的package包/类
private static void checkIsDAG(List<QueryQueueRule> rules)
{
    DirectedPseudograph<String, DefaultEdge> graph = new DirectedPseudograph<>(DefaultEdge.class);
    for (QueryQueueRule rule : rules) {
        String lastQueueName = null;
        for (QueryQueueDefinition queue : rule.getQueues()) {
            String currentQueueName = queue.getTemplate();
            graph.addVertex(currentQueueName);
            if (lastQueueName != null) {
                graph.addEdge(lastQueueName, currentQueueName);
            }
            lastQueueName = currentQueueName;
        }
    }

    List<String> shortestCycle = shortestCycle(graph);

    if (shortestCycle != null) {
        String s = Joiner.on(", ").join(shortestCycle);
        throw new IllegalArgumentException(format("Queues must not contain a cycle. The shortest cycle found is [%s]", s));
    }
}
 
开发者ID:y-lan,项目名称:presto,代码行数:23,代码来源:SqlQueryQueueManager.java

示例3: addUniqueEdge

import org.jgrapht.graph.DirectedPseudograph; //导入依赖的package包/类
private void addUniqueEdge(DirectedPseudograph<ClassBox, DirectedClassBoxRelationship> dia, ObjectPropertyRestriction opr) {
	// if this edge already exists in the psuedograph, use the most appropriate multiplicity
	for(DirectedClassBoxRelationship edge : dia.getAllEdges(opr.getSource(), opr.getTarget())) {
		if(edge instanceof ObjectPropertyRestriction) {
			ObjectPropertyRestriction eopr = (ObjectPropertyRestriction)edge;
			if(eopr.getOWLObjectProperty().equals(opr.getOWLObjectProperty())) {
				// a duplicate has been detected! reject the one with the weaker multiplicity
				if(opr.getMultiplicity().isTighterThan(eopr.getMultiplicity())) {
					// remove eopr and replace it with opr
					dia.removeEdge(eopr);
					dia.addEdge(opr.getSource(), opr.getTarget(), opr);
					logger.warn("Duplicate edge detected; Replacing " + eopr + " with " + opr + ".");
					return;
				}
				else {
					logger.warn("Duplicate edge detected; Ignoring " + opr + " in relation to " + eopr + ".");
					return;
				}
			}
		}
	}		
	// otherwise, add the edge
	dia.addEdge(opr.getSource(), opr.getTarget(), opr);
}
 
开发者ID:dratc,项目名称:owl2diagram,代码行数:25,代码来源:OWLDiagramRenderer.java

示例4: main

import org.jgrapht.graph.DirectedPseudograph; //导入依赖的package包/类
public static void main(String[] args) {
	DirectedPseudograph<String, Edge> g = new DirectedPseudograph<String, Edge>(
			Edge.class);

	long time = System.currentTimeMillis();
	Utils.reportPerformanceFor("starting at", time);

	GraphBuilder.buildRandomically(g, Integer.parseInt(args[0]),
			Integer.parseInt(args[1]));

	Utils.reportPerformanceFor("random graph generation", time);

	System.out.println("no of vertices: " + g.vertexSet().size());
	System.out.println("no of edges: " + g.edgeSet().size());

	HawickJamesSimpleCycles<String, Edge> hj = new HawickJamesSimpleCycles<String, Edge>(
			g);

	hj.printSimpleCycles();
}
 
开发者ID:lzkill,项目名称:hawickjames,代码行数:21,代码来源:PrintElementaryCircuitsFromRandom.java

示例5: GKAGraph

import org.jgrapht.graph.DirectedPseudograph; //导入依赖的package包/类
private GKAGraph(GraphType type){
	this.type = type;
	
	// Choose if it will be directed or undirected
	if (isDirected()){
		jGraph = new ListenableDirectedGraph<>(new DirectedPseudograph<>(GKAEdge.class));
	}else{
		jGraph = new ListenableUndirectedGraph<>(new Pseudograph<>(GKAEdge.class));
	}
	
	// JGXAdapter for showing the Graph in Swing
	mxgraph = new JGraphXAdapter<>(getjGraph());
	
	// Changing EdgeStyle when is undirected
	if (!isDirected()){
		getMxgraph().getStylesheet().getDefaultEdgeStyle().put(mxConstants.STYLE_ENDARROW, "none");
	}
	setGraphConfig();
}
 
开发者ID:JanaWengenroth,项目名称:GKA1,代码行数:20,代码来源:GKAGraph.java

示例6: of

import org.jgrapht.graph.DirectedPseudograph; //导入依赖的package包/类
public static DirectedPseudograph<Instance, CommunicationInstanceEdge> of(
        ApplicationInstance applicationInstance) {

    DirectedPseudograph<Instance, CommunicationInstanceEdge> instanceGraph =
            new DirectedPseudograph<>(new CommunicationInstanceEdgeFactory());

    applicationInstance.getInstances().forEach(instanceGraph::addVertex);
    applicationInstance.getInstances().forEach(new Consumer<Instance>() {
        @Override
        public void accept(Instance instance) {
            for (Instance targetInstance : instance.getTargetCommunicationInstances()) {
                instanceGraph.addEdge(instance, targetInstance);
            }
        }
    });

    return instanceGraph;
}
 
开发者ID:cloudiator,项目名称:colosseum,代码行数:19,代码来源:ApplicationInstanceGraph.java

示例7: createGraph

import org.jgrapht.graph.DirectedPseudograph; //导入依赖的package包/类
private DirectedPseudograph<String, String> createGraph() throws IOException {
	DirectedPseudograph<String, String> graph = new DirectedPseudograph<String, String>(new UnsupportedEdgeFactory<String, String>());
	ObjectProducer<String, String> objectProducer = new ObjectProducer<String, String>() {
		@Override
		public String createEdge(String source, String target, String edgeLabel) {
			return source + "-->" + target + ":" + edgeLabel;
		}
		
		@Override
		public String createVertex(String vertexLabel) {
			return vertexLabel;
		}
	};
	new SimpleGraphReader<String, String>(graph, objectProducer).readGraph(new StringReader(GRAPH_CONTENT));
	return graph;
}
 
开发者ID:andreasbehnke,项目名称:javaan,代码行数:17,代码来源:TestMinimumEdgesCycleCut.java

示例8: testCutCycles

import org.jgrapht.graph.DirectedPseudograph; //导入依赖的package包/类
@Test
public void testCutCycles() throws IOException {
	DirectedPseudograph<String, String> source = createGraph();
	DirectedGraph<String, String> target = new DirectedMultigraph<>(new UnsupportedEdgeFactory<String, String>());
	target = new MinimumEdgesCycleCut<String, String>(source, target).cutCycles();
	
	assertTrue(source.edgeSet().contains("a-->b:ab1"));
	assertFalse(target.edgeSet().contains("a-->b:ab1"));

	assertTrue(source.edgeSet().contains("e-->b:eb1"));
	assertFalse(target.edgeSet().contains("e-->b:eb1"));
	
	assertTrue(source.edgeSet().contains("x-->y:xy1"));
	assertFalse(target.edgeSet().contains("x-->y:xy1"));

	assertTrue(source.edgeSet().contains("v-->v:vv1"));
	assertTrue(source.edgeSet().contains("v-->v:vv2"));
	assertFalse(target.edgeSet().contains("v-->v:vv1"));
	assertFalse(target.edgeSet().contains("v-->v:vv2"));
}
 
开发者ID:andreasbehnke,项目名称:javaan,代码行数:21,代码来源:TestMinimumEdgesCycleCut.java

示例9: equals

import org.jgrapht.graph.DirectedPseudograph; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public boolean equals(Object obj) {
    if (this == obj) {
        return true;
    } else if (obj == null) {
        return false;
    } else if (!(obj instanceof AbstractGraph)) {
        return false;
    } else {
        AbstractGraph other = (AbstractGraph) obj;
        DirectedPseudograph<State, Transition> otherDelegate = (DirectedPseudograph<State, Transition>) other.delegate;
        return delegate.equals(otherDelegate);
    }
}
 
开发者ID:julianthome,项目名称:autorex,代码行数:15,代码来源:AbstractGraph.java

示例10: buildGraph

import org.jgrapht.graph.DirectedPseudograph; //导入依赖的package包/类
private DirectedPseudograph<Resource, Edge> buildGraph(RepositoryConnection repo, URI[] uris, Set<String>ignored)
        throws RepositoryException {
    DirectedPseudograph<Resource, Edge> result = new DirectedPseudograph<Resource, Edge>(Edge.class);

    Set<Statement> consumed = new HashSet<Statement>();

    for (URI uri : uris) {
        buildGraphAddAll(result, repo.getStatements(uri, null, null, true), consumed, ignored);
        buildGraphAddAll(result, repo.getStatements(null, null, uri, true), consumed, ignored);
    }

    return result;
}
 
开发者ID:DrDub,项目名称:Alusivo,代码行数:14,代码来源:GraphAlgorithm.java

示例11: neighbors

import org.jgrapht.graph.DirectedPseudograph; //导入依赖的package包/类
private Set<Edge> neighbors(DirectedPseudograph<Resource, Edge> candidate,
        DirectedPseudograph<Resource, Edge> fullGraph) {
    Set<Edge> result = new HashSet<>();
    for (Resource node : candidate.vertexSet())
        for (Edge e : fullGraph.outgoingEdgesOf(node)) {
            if (candidate.containsEdge(e))
                continue;
            result.add(e);
        }
    return result;
}
 
开发者ID:DrDub,项目名称:Alusivo,代码行数:12,代码来源:GraphAlgorithm.java

示例12: containedPropertiesInSubgraph

import org.jgrapht.graph.DirectedPseudograph; //导入依赖的package包/类
private boolean containedPropertiesInSubgraph(Resource node1, DirectedPseudograph<Resource, Edge> subGraph,
        Resource node2, DirectedPseudograph<Resource, Edge> fullGraph) {
    Set<Edge> basicProperties = subGraph.getAllEdges(node1, node1);
    if (!fullGraph.getAllEdges(node2, node2).containsAll(basicProperties)) {
        return false;
    }
    return true;
}
 
开发者ID:DrDub,项目名称:Alusivo,代码行数:9,代码来源:GraphAlgorithm.java

示例13: matchGraphs

import org.jgrapht.graph.DirectedPseudograph; //导入依赖的package包/类
private boolean matchGraphs(Resource referent, DirectedPseudograph<Resource, Edge> candidate, Resource other,
        DirectedPseudograph<Resource, Edge> fullGraph, long startTime) throws ReferringExpressionException {

    if (!containedPropertiesInSubgraph(referent, candidate, other, fullGraph))
        return false;

    if (System.currentTimeMillis() - startTime > maxTime)
        throw new ReferringExpressionException("Time-out");

    Map<Resource, Resource> bijection = new HashMap<>();
    bijection.put(referent, other);

    return matchHelper(bijection, neighbors(candidate, referent), fullGraph, candidate, startTime);
}
 
开发者ID:DrDub,项目名称:Alusivo,代码行数:15,代码来源:GraphAlgorithm.java

示例14: GGraph

import org.jgrapht.graph.DirectedPseudograph; //导入依赖的package包/类
public GGraph(DirectedPseudograph<GVertex, GEdge> gGraph) {
    this.gGraph = gGraph;
    vertexMap = new HashMap<>();
    for(GVertex gVertex : gGraph.vertexSet()) {
        vertexMap.put(gVertex.getName(),gVertex);
    }
}
 
开发者ID:bergeoisie,项目名称:jtextiles,代码行数:8,代码来源:GGraph.java

示例15: of

import org.jgrapht.graph.DirectedPseudograph; //导入依赖的package包/类
public static DirectedPseudograph<ApplicationComponent, CommunicationEdge> of(
    Application application, boolean onlyMandatory) {

    DirectedPseudograph<ApplicationComponent, CommunicationEdge> componentGraph =
        new DirectedPseudograph<>(CommunicationEdge.class);
    application.getApplicationComponents().forEach(componentGraph::addVertex);

    application.communications().stream()
        .filter(communication -> !onlyMandatory || communication.isMandatory()).forEach(
        communication -> componentGraph
            .addEdge(communication.getSource(), communication.getTarget(),
                new CommunicationEdge(communication)));
    return componentGraph;
}
 
开发者ID:cloudiator,项目名称:colosseum,代码行数:15,代码来源:ApplicationTypeGraph.java


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