本文整理汇总了Java中org.jgrapht.graph.ListenableDirectedGraph类的典型用法代码示例。如果您正苦于以下问题:Java ListenableDirectedGraph类的具体用法?Java ListenableDirectedGraph怎么用?Java ListenableDirectedGraph使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ListenableDirectedGraph类属于org.jgrapht.graph包,在下文中一共展示了ListenableDirectedGraph类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ResourceTypeManager
import org.jgrapht.graph.ListenableDirectedGraph; //导入依赖的package包/类
/**
* Adds the given types to the manager, building a graph to represent the type hierarchy.
*
* @param resourceTypeSetMap a full set of types, must be immutable
* @param setsToUse optional set of type names that the manager to care about - it will ignore others it finds. If
* null, then the full set is used (by "full set" it means the resourceTypeSetMap param).
* @throws IllegalStateException if types are missing (e.g. a type needs a parent but the parent is missing)
*/
public ResourceTypeManager(Map<Name, TypeSet<ResourceType<L>>> resourceTypeSetMap, Collection<Name> setsToUse)
throws IllegalStateException {
// If setsToUse is null, that means we need to use all the ones in the incoming map.
// If setsToUse is not null, just use those named sets and ignore the others.
if (setsToUse == null) {
this.typeSetMap = resourceTypeSetMap;
} else {
Map<Name, TypeSet<ResourceType<L>>> m = new HashMap<>();
for (Name setToUse : setsToUse) {
if (resourceTypeSetMap.containsKey(setToUse)) {
m.put(setToUse, resourceTypeSetMap.get(setToUse));
}
}
this.typeSetMap = Collections.unmodifiableMap(m);
}
this.resourceTypesGraph = new ListenableDirectedGraph<>(DefaultEdge.class);
this.index = new DirectedNeighborIndex<>(this.resourceTypesGraph);
this.resourceTypesGraph.addGraphListener(index);
prepareGraph();
}
示例2: GKAGraph
import org.jgrapht.graph.ListenableDirectedGraph; //导入依赖的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();
}
示例3: stringGraph
import org.jgrapht.graph.ListenableDirectedGraph; //导入依赖的package包/类
/**
* @return
*/
public static Graph<String, DefaultEdge> stringGraph()
{
final Graph<String, DefaultEdge> g = new ListenableDirectedGraph<>(
DefaultEdge.class);
g.addVertex("v1");
g.addVertex("v2");
g.addVertex("v3");
g.addVertex("v4");
g.addEdge("v1", "v2");
g.addEdge("v2", "v3");
g.addEdge("v3", "v1");
g.addEdge("v4", "v3");
return g;
}
示例4: handleInform
import org.jgrapht.graph.ListenableDirectedGraph; //导入依赖的package包/类
private List<WorkingPlan> handleInform(PlanParameter param, Desire des, ListenableDirectedGraph<GraphNode, DefaultEdge> graph) {
List<WorkingPlan> plans = new ArrayList<>();
Inform toReact = (Inform)des.getPerception();
if(toReact.getSentences().size() == 0)
return plans;
Set<FolFormula> infered = param.getAgent().getBeliefs().getWorldKnowledge().infere();
for(FolFormula info : toReact.getSentences()) {
if(!infered.contains(info)) {
FolParserB parser = new FolParserB(new StringReader("not_sure(" + info.toString() + ")"));
FolFormula formula = null;
try {
formula = parser.formula(new FolSignature());
Desire tempDes = new Desire(formula, toReact);
plans.addAll(handeDefaultDesire(param, tempDes, graph));
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
continue;
}
}
}
return plans;
}
示例5: handeDefaultDesire
import org.jgrapht.graph.ListenableDirectedGraph; //导入依赖的package包/类
private List<WorkingPlan> handeDefaultDesire(PlanParameter param, Desire des,
ListenableDirectedGraph<GraphNode, DefaultEdge> graph) {
planningStrategy.setPenaltyTemplate(getPenaltyFunction(param));
planningStrategy.setPlanConverter(getPlanConverter(param));
int alternatives = Integer.parseInt(param.getSetting("alternatives", "0"));
double targetLOD = Double.parseDouble(param.getSetting("targetLOD", "1"));
List<WorkingPlan> plans = planningStrategy.controlPlan(graph, des, alternatives, targetLOD);
String output = String.format("The desire '%s' generates", des.toString());
if(plans.isEmpty()) {
output += " no plans";
} else {
output += String.format(" the plan '%s'", plans.toString());
}
LOG.info(output);
return plans;
}
示例6: getAST
import org.jgrapht.graph.ListenableDirectedGraph; //导入依赖的package包/类
public Graph<ASTNode, DefaultEdge> getAST() {
Graph<ASTNode, DefaultEdge> ast = new ListenableDirectedGraph<>(DefaultEdge.class);
ast.addVertex(this);
body.forEach(node -> {
node.addDependency(ast);
ast.addEdge(this, node);
});
return ast;
}
示例7: DSLPanel
import org.jgrapht.graph.ListenableDirectedGraph; //导入依赖的package包/类
/**
* Creates new form DSLPanel
*/
public DSLPanel() {
initComponents();
Document doc = textInput.getDocument();
doc.putProperty(PlainDocument.tabSizeAttribute, 2);
GlobalOutputStream.PRINTER = msg -> {
textOutput.append(msg + "\n");
};
runButton.addActionListener(e -> {
tearDown();
DSLLexer lexer = new DSLLexer(textInput.getText());
lexer.nextToken();
DSL dsl = new DSL(lexer);
try {
dsl.parse();
} catch (Exception ex) {
JOptionPane.showMessageDialog(
this,
ex.getMessage(),
"Error",
JOptionPane.ERROR_MESSAGE
);
return;
}
createAST();
createCFG();
SymbolTable.clear();
});
graph = new ListenableDirectedGraph<>(DefaultEdge.class);
}
示例8: tearDown
import org.jgrapht.graph.ListenableDirectedGraph; //导入依赖的package包/类
public void tearDown() {
roots.clear();
SymbolTable.clear();
graph = new ListenableDirectedGraph<>(DefaultEdge.class);
destroyCFG();
destroyAST();
}
示例9: reinitializeIfNecessary
import org.jgrapht.graph.ListenableDirectedGraph; //导入依赖的package包/类
/**
* Always call with {@link #graphLockWrite} locked.
*/
private void reinitializeIfNecessary() {
if (this.resourceCache == null || this.resourceCache.size() > 0) {
this.resourcesGraph = new ListenableDirectedGraph<>(DefaultEdge.class);
this.neighborIndex = new DirectedNeighborIndex<>(this.resourcesGraph);
this.resourcesGraph.addGraphListener(neighborIndex);
this.resourceCache = new HashMap<>();
this.resourcesGraph.addVertexSetListener(new VertexCacheListener());
}
}
示例10: _asGraph
import org.jgrapht.graph.ListenableDirectedGraph; //导入依赖的package包/类
private ListenableDirectedGraph<NamedNode, DefaultEdge> _asGraph(StormTopology t) {
final Map<String, Bolt> bolts = t.get_bolts();
final Map<String, SpoutSpec> spouts = t.get_spouts();
final ListenableDirectedGraph<NamedNode, DefaultEdge> ret = new ListenableDirectedGraph<NamedNode, DefaultEdge>(
DefaultEdge.class);
createSpouts(spouts, ret);
createBolts(bolts, ret);
createConnections(bolts, ret);
return ret;
}
示例11: createConnections
import org.jgrapht.graph.ListenableDirectedGraph; //导入依赖的package包/类
private void createConnections(Map<String, Bolt> bolts, ListenableDirectedGraph<NamedNode, DefaultEdge> ret) {
for (final Entry<String, Bolt> boltspec : bolts.entrySet()) {
final Bolt bolt = boltspec.getValue();
final String id = boltspec.getKey();
final Map<GlobalStreamId, Grouping> inputs = bolt.get_common().get_inputs();
for (final Entry<GlobalStreamId, Grouping> input : inputs.entrySet()) {
final GlobalStreamId from = input.getKey();
// Grouping grouping = input.getValue();
final String fromId = from.get_componentId();
// String streamId = from.get_streamId();
ret.addEdge(nns.get(fromId), nns.get(id));
}
}
}
示例12: createSpouts
import org.jgrapht.graph.ListenableDirectedGraph; //导入依赖的package包/类
private void createSpouts(Map<String, SpoutSpec> spouts, ListenableDirectedGraph<NamedNode, DefaultEdge> ret) {
for (final Entry<String, SpoutSpec> spoutEntries : spouts.entrySet()) {
final String name = spoutEntries.getKey();
if (!nns.containsKey(name))
nns.put(name, new NamedNode(name, Type.SPOUT));
ret.addVertex(nns.get(name));
}
}
示例13: createBolts
import org.jgrapht.graph.ListenableDirectedGraph; //导入依赖的package包/类
private void createBolts(Map<String, Bolt> bolts, ListenableDirectedGraph<NamedNode, DefaultEdge> ret) {
for (final Entry<String, Bolt> boltEntries : bolts.entrySet()) {
final String name = boltEntries.getKey();
if (!nns.containsKey(name))
nns.put(name, new NamedNode(name, Type.BOLT));
ret.addVertex(nns.get(name));
}
}
示例14: loadTest
import org.jgrapht.graph.ListenableDirectedGraph; //导入依赖的package包/类
/**
* Tests the JGraphXAdapter with 1.000 nodes and 1.000 edges.
*/
@Test
public void loadTest()
{
final int maxVertices = 1000;
final int maxEdges = 1000;
ListenableGraph<Integer, DefaultEdge> jGraphT
= new ListenableDirectedGraph<Integer, DefaultEdge>(
DefaultEdge.class);
for (int i = 0; i < maxVertices; i++) {
jGraphT.addVertex(i);
}
for (int i = 0; i < maxEdges; i++) {
jGraphT.addEdge(i, (i + 1) % jGraphT.vertexSet().size());
}
JGraphXAdapter<Integer, DefaultEdge> graphX = null;
try {
graphX = new JGraphXAdapter<Integer, DefaultEdge>(jGraphT);
} catch (Exception e) {
fail("Unexpected error while creating JgraphXAdapter with"
+ maxVertices + " vertices and " + maxEdges + " Edges");
}
testMapping(graphX);
}
示例15: init
import org.jgrapht.graph.ListenableDirectedGraph; //导入依赖的package包/类
@Override
public void init() {
graph = new ListenableDirectedGraph<>(DefaultEdge.class);
adapter = new JGraphModelAdapter(graph);
jgraph = new JGraph(adapter);
adjustDisplaySettings(jgraph);
getContentPane( ).add(jgraph );
resize( DEFAULT_SIZE );
Main.main(null);
ProgramASTNode progNode = new ProgramASTNode(roots.toArray(new ASTNode[0]));
CFG cfg = progNode.createCFG();
// System.out.println(cfg.reduce());
// JGraph cfgGraph = new JGraph(new JGraphXAdapter(cfg.getGraph()));
JGraphXAdapter jgxAdapter = new JGraphXAdapter(cfg.getGraph());
jgxAdapter.setAutoSizeCells(true);
jgxAdapter.setCellsResizable(true);
// jgxAdapter.alignCells(mxConstants.ALIGN_CENTER);
mxStylesheet stylesheet = jgxAdapter.getStylesheet();
Hashtable<String, Object> style = new Hashtable<String, Object>();
style.put(mxConstants.STYLE_SHAPE, mxConstants.SHAPE_RECTANGLE);
style.put(mxConstants.STYLE_OPACITY, 50);
style.put(mxConstants.STYLE_FONTCOLOR, "#774400");
stylesheet.putCellStyle("ROUNDED", style);
jgxAdapter.setStylesheet(stylesheet);
jgxAdapter.getStylesheet().getDefaultEdgeStyle().put(mxConstants.STYLE_NOLABEL, "1");
mxGraphComponent graphComponent = new mxGraphComponent(jgxAdapter);
graphComponent.setWheelScrollingEnabled(false);
mxGraphModel graphModel = (mxGraphModel)graphComponent.getGraph().getModel();
// Collection<Object> cells = graphModel.getCells().values();
// mxUtils.setCellStyles(graphComponent.getGraph().getModel(),
// cells.toArray(), mxConstants.STYLE_ENDARROW, mxConstants.NONE);
getContentPane().add(graphComponent);
mxHierarchicalLayout layout = new mxHierarchicalLayout(jgxAdapter);
layout.execute(jgxAdapter.getDefaultParent());
this.addMouseWheelListener(e -> {
mxGraphView view = graphComponent.getGraph().getView();
int notches = e.getWheelRotation();
double scale = view.getScale();
double newScale = view.getScale() - ((double) notches / 61.8033988272);
view.setScale(newScale);
});
// adjustDisplaySettings(cfgGraph);
// getContentPane().add(cfgGraph);
// final JGraphTreeLayout hir = new JGraphTreeLayout();
// final JGraphFacade graphFacade = new JGraphFacade(cfgGraph, new Object[] {cfg.start});
// graphFacade.setOrdered(true);
// hir.setPositionMultipleTrees(true);
// hir.setTreeDistance(50);
// hir.setLevelDistance(50);
// hir.run(graphFacade);
// final Map nestedMap = graphFacade.createNestedMap(true, true);
// cfgGraph.getGraphLayoutCache().edit(nestedMap);
// SwingUtilities.invokeLater(() -> {
// mxGraphView view = graphComponent.getGraph().getView();
// int compLen = graphComponent.getWidth();
// int viewLen = (int)view.getGraphBounds().getWidth();
// System.out.println("Complen: " + compLen + ", viewlen: " + viewLen);
// System.out.println("Scale: " + (double)compLen/viewLen * view.getScale());
// view.setScale(2);
// });
}