• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ListenableDirectedGraph类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



ListenableDirectedGraph类属于org.jgrapht.graph包,在下文中一共展示了ListenableDirectedGraph类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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();
}
 
开发者ID:hawkular,项目名称:hawkular-agent,代码行数:31,代码来源:ResourceTypeManager.java


示例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();
}
 
开发者ID:JanaWengenroth,项目名称:GKA1,代码行数:20,代码来源:GKAGraph.java


示例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;
}
 
开发者ID:openfurther,项目名称:further-open-core,代码行数:20,代码来源:GraphTestUtil.java


示例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;
}
 
开发者ID:Angerona,项目名称:angerona-framework,代码行数:26,代码来源:KnowhowGraphSubgoal.java


示例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;
}
 
开发者ID:Angerona,项目名称:angerona-framework,代码行数:20,代码来源:KnowhowGraphSubgoal.java


示例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;
}
 
开发者ID:LouisJenkinsCS,项目名称:DSL,代码行数:11,代码来源:ProgramASTNode.java


示例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);
}
 
开发者ID:LouisJenkinsCS,项目名称:DSL,代码行数:36,代码来源:DSLPanel.java


示例8: tearDown

import org.jgrapht.graph.ListenableDirectedGraph; //导入依赖的package包/类
public void tearDown() {
    roots.clear();
    SymbolTable.clear();
    graph = new ListenableDirectedGraph<>(DefaultEdge.class);
    destroyCFG();
    destroyAST();
}
 
开发者ID:LouisJenkinsCS,项目名称:DSL,代码行数:8,代码来源:DSLPanel.java


示例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());
    }
}
 
开发者ID:hawkular,项目名称:hawkular-agent,代码行数:13,代码来源:ResourceManager.java


示例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;
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:12,代码来源:StormGraphCreator.java


示例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));
		}

	}
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:16,代码来源:StormGraphCreator.java


示例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));
	}
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:9,代码来源:StormGraphCreator.java


示例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));
	}
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:9,代码来源:StormGraphCreator.java


示例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);

}
 
开发者ID:JanaWengenroth,项目名称:GKA1,代码行数:34,代码来源:JGraphXAdapterTest.java


示例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);
//        });
    }
 
开发者ID:LouisJenkinsCS,项目名称:DSL,代码行数:72,代码来源:ASTGraph.java


示例16: CFG

import org.jgrapht.graph.ListenableDirectedGraph; //导入依赖的package包/类
public CFG(Graph<BasicBlock, DefaultEdge> graph) {
    this.graph = graph == null ? new ListenableDirectedGraph<>(DefaultEdge.class) : graph;
}
 
开发者ID:LouisJenkinsCS,项目名称:DSL,代码行数:4,代码来源:CFG.java


示例17: genericTest

import org.jgrapht.graph.ListenableDirectedGraph; //导入依赖的package包/类
/**
 * Test scenarios under normal conditions.
 */
@Test
public void genericTest() 
{
    ListenableGraph<String, DefaultEdge> jGraphT 
     = new ListenableDirectedGraph<String, DefaultEdge>(DefaultEdge.class);

    // fill graph with data
    String v1 = "Vertex 1";
    String v2 = "Vertex 2";
    String v3 = "Vertex 3";
    String v4 = "Vertex 4";

    jGraphT.addVertex(v1);
    jGraphT.addVertex(v2);
    jGraphT.addVertex(v3);
    jGraphT.addVertex(v4);

    final int expectedEdges = 5;
    jGraphT.addEdge(v1, v2);
    jGraphT.addEdge(v1, v3);
    jGraphT.addEdge(v1, v4);
    jGraphT.addEdge(v2, v3);
    jGraphT.addEdge(v3, v4);

    // Create jgraphx graph and test it
    JGraphXAdapter<String, DefaultEdge> graphX = 
            new JGraphXAdapter<String, DefaultEdge>(jGraphT);
    testMapping(graphX);
    
    // test if all values are in the jgraphx graph
    Object[] expectedArray = {v1, v2, v3, v4};
    Arrays.sort(expectedArray);
    
    Object[] realArray = graphX.getCellToVertexMap().values().toArray(); 
    Arrays.sort(realArray);
    Assert.assertArrayEquals(expectedArray, realArray);
    
    realArray = graphX.getVertexToCellMap().keySet().toArray();
    Arrays.sort(realArray);
    Assert.assertArrayEquals(expectedArray, realArray);
    
    int edgesCount = graphX.getCellToEdgeMap().values().size();
    Assert.assertEquals(expectedEdges, edgesCount);
    
    edgesCount = graphX.getEdgeToCellMap().keySet().size();
    Assert.assertEquals(expectedEdges, edgesCount);
}
 
开发者ID:JanaWengenroth,项目名称:GKA1,代码行数:51,代码来源:JGraphXAdapterTest.java


示例18: listenerTest

import org.jgrapht.graph.ListenableDirectedGraph; //导入依赖的package包/类
/**
 * Tests the correct implementation of the GraphListener interface.
 */
@Test
public void listenerTest() 
{
    ListenableGraph<String, String> jGraphT 
        = new ListenableDirectedGraph<String, String>(String.class);
    
    JGraphXAdapter<String, String> graphX 
        = new JGraphXAdapter<String, String>(jGraphT);
    
    // add some data to the jgrapht graph - changes should be propagated
    // through jgraphxadapters graphlistener interface

    String v1 = "Vertex 1";
    String v2 = "Vertex 2";
    String v3 = "Vertex 3";
    String v4 = "Vertex 4";

    jGraphT.addVertex(v1);
    jGraphT.addVertex(v2);
    jGraphT.addVertex(v3);
    jGraphT.addVertex(v4);

    jGraphT.addEdge(v1, v2, "Edge 1");
    jGraphT.addEdge(v1, v3, "Edge 2");
    jGraphT.addEdge(v1, v4, "Edge 3");
    jGraphT.addEdge(v2, v3, "Edge 4");
    jGraphT.addEdge(v3, v4, "Edge 5");
    
    int expectedEdges = jGraphT.edgeSet().size();

    testMapping(graphX);
    
    // test if all values are in the jgraphx graph
    Object[] expectedArray = {v1, v2, v3, v4};
    Arrays.sort(expectedArray);
    
    Object[] realArray = graphX.getCellToVertexMap().values().toArray(); 
    Arrays.sort(realArray);
    Assert.assertArrayEquals(expectedArray, realArray);
    
    realArray = graphX.getVertexToCellMap().keySet().toArray();
    Arrays.sort(realArray);
    Assert.assertArrayEquals(expectedArray, realArray);
    
    int edgesCount = graphX.getCellToEdgeMap().values().size();
    Assert.assertEquals(expectedEdges, edgesCount);
    
    edgesCount = graphX.getEdgeToCellMap().keySet().size();
    Assert.assertEquals(expectedEdges, edgesCount);
    
    
    // remove some data from the jgraphT graph
   jGraphT.removeVertex(v4);
   jGraphT.removeVertex(v3);
   
   jGraphT.removeEdge(v1, v2);
   
   int expectedEdgesAfterRemove = jGraphT.edgeSet().size();
   
    // test if all values are in the jgraphx graph
    expectedArray = new Object[] {v1, v2};
    Arrays.sort(expectedArray);
    
    realArray = graphX.getCellToVertexMap().values().toArray(); 
    Arrays.sort(realArray);
    Assert.assertArrayEquals(expectedArray, realArray);
    
    realArray = graphX.getVertexToCellMap().keySet().toArray();
    Arrays.sort(realArray);
    Assert.assertArrayEquals(expectedArray, realArray);
    
    edgesCount = graphX.getCellToEdgeMap().values().size();
    Assert.assertEquals(expectedEdgesAfterRemove, edgesCount);
    
    edgesCount = graphX.getEdgeToCellMap().keySet().size();
    Assert.assertEquals(expectedEdgesAfterRemove, edgesCount);
}
 
开发者ID:JanaWengenroth,项目名称:GKA1,代码行数:81,代码来源:JGraphXAdapterTest.java


示例19: duplicateEntriesTest

import org.jgrapht.graph.ListenableDirectedGraph; //导入依赖的package包/类
/**
 * Test if duplicate Entries are saved only once.
 */
@Test
public void duplicateEntriesTest() 
{
    ListenableGraph<String, DefaultEdge> jGraphT 
     = new ListenableDirectedGraph<String, DefaultEdge>(DefaultEdge.class);
    
    JGraphXAdapter<String, DefaultEdge> graphX = 
            new JGraphXAdapter<String, DefaultEdge>(jGraphT);

    // fill graph with data
    String v1 = "Vertex 1";
    String v2 = "Vertex 2";
    String v3 = "Vertex 3";
    String v4 = "Vertex 4";
    DefaultEdge edge1 = new DefaultEdge();

    jGraphT.addVertex(v1);
    jGraphT.addVertex(v2);
    jGraphT.addVertex(v3);
    jGraphT.addVertex(v4);
    jGraphT.addVertex(v1);
    jGraphT.addVertex(v2);
    jGraphT.addVertex(v3);
    jGraphT.addVertex(v4);

    /*
     * edge1 is added 3 times with different source/target vertices it
     * should only add it once. A new edge is added with source-target
     * combination already in the graph it should not be added to the graph.
     */
    final int expectedEdges = 3;
    jGraphT.addEdge(v1, v2, edge1);
    jGraphT.addEdge(v1, v2, new DefaultEdge());
    jGraphT.addEdge(v1, v3, edge1);
    jGraphT.addEdge(v1, v4, edge1);
    jGraphT.addEdge(v2, v3);
    jGraphT.addEdge(v3, v4);

    testMapping(graphX);
    
    // test if all values are in the jgraphx graph
    Object[] expectedArray = {v1, v2, v3, v4};
    Arrays.sort(expectedArray);
    
    Object[] realArray = graphX.getCellToVertexMap().values().toArray(); 
    Arrays.sort(realArray);
    Assert.assertArrayEquals(expectedArray, realArray);
    
    realArray = graphX.getVertexToCellMap().keySet().toArray();
    Arrays.sort(realArray);
    Assert.assertArrayEquals(expectedArray, realArray);
    
    int edgesCount = graphX.getCellToEdgeMap().values().size();
    Assert.assertEquals(expectedEdges, edgesCount);
    
    edgesCount = graphX.getEdgeToCellMap().keySet().size();
    Assert.assertEquals(expectedEdges, edgesCount);
}
 
开发者ID:JanaWengenroth,项目名称:GKA1,代码行数:62,代码来源:JGraphXAdapterTest.java


示例20: processImpl

import org.jgrapht.graph.ListenableDirectedGraph; //导入依赖的package包/类
@Override
protected Boolean processImpl(PlanParameter param) {
	param.report("Using Knowhow for Subgoal Generation.");
	
	KnowhowGraph comp = param.getAgent().getComponent(KnowhowGraph.class);
	if(comp == null) {
		LOG.warn("Using KnowhowGraphSubgoal without KnowhowGraph data component");
		return super.processImpl(param);
	}
	ListenableDirectedGraph<GraphNode, DefaultEdge> graph = comp.getGraph();
	
	boolean gen  = false;
	for (Desire des : param.getAgent().getComponent(Desires.class).getDesires()) {			
		if(param.getActualPlan().countPlansFor(des) > 0)
			continue;
		
		List<WorkingPlan> plans = new ArrayList<>();
		if(des.getFormula().toString().startsWith("revisionRequestProcessing")) {	
			plans = handleInform(param, des, graph);
		} else if(des.getFormula().toString().startsWith(GenerateOptionsOperator.prepareQueryProcessing.getName())) {
			Query context = (Query)des.getPerception();
			String desAsStr = "answer_query(" + context.getQuestion().toString() +")";
			FolParserB parser = new FolParserB(new StringReader(desAsStr));
			FolFormula formula = null;
			try {
				formula = parser.formula(new FolSignature());
			} catch (ParseException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			if(formula != null) {
				Desire extDes = new Desire(formula, context);
				plans = handeDefaultDesire(param, extDes, graph);
			}
			
			if(plans.isEmpty()) {
				Desire defDes = new Desire(new FOLAtom(new Predicate("answer_query")), des.getPerception());
				plans = handeDefaultDesire(param, defDes, graph);
			}
		} else {
			plans = handeDefaultDesire(param, des, graph);
		}
		
		gen = translate(plans, param, des) || gen;
	}
	
	if(gen)
		return true;
	else
		return super.processImpl(param);
}
 
开发者ID:Angerona,项目名称:angerona-framework,代码行数:52,代码来源:KnowhowGraphSubgoal.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java XmlTagImpl类代码示例发布时间:2022-05-23
下一篇:
Java HostApp类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap