コード例 #1
0
 /** Tests if all anchor images in a given event actually occur in the graph. */
 private void checkEvent(RuleEvent event) {
   if (event instanceof CompositeEvent) {
     for (RuleEvent subEvent : ((CompositeEvent) event).getEventSet()) {
       checkEvent(subEvent);
     }
   } else {
     for (int i = 0; i < event.getRule().getAnchor().size(); i++) {
       AnchorValue anchorImage = event.getAnchorImage(i);
       HostGraph host = MatchCollector.this.state.getGraph();
       boolean instanceCondition = !(anchorImage instanceof ValueNode);
       boolean edgeCondition = !host.containsEdge((HostEdge) anchorImage);
       if (anchorImage.getAnchorKind() == AnchorKind.EDGE && edgeCondition) {
         assert false : String.format("Edge %s does not occur in graph %s", anchorImage, host);
       } else if (anchorImage.getAnchorKind() == AnchorKind.NODE
           && instanceCondition
           && edgeCondition) {
         assert false : String.format("Node %s does not occur in graph %s", anchorImage, host);
       }
     }
   }
 }
コード例 #2
0
 /** Builds the connection map for a given host graph. */
 private Map<Record, List<Record>> buildConnect(HostGraph host) {
   this.recordMap.clear();
   Map<Record, List<Record>> connect = new LinkedHashMap<Record, List<Record>>();
   for (TypeEdge check : this.checks) {
     Set<? extends HostEdge> edges = host.edgeSet(check.label());
     for (HostEdge edge : edges) {
       Record source = getRecord(edge.source());
       List<Record> targets = connect.get(source);
       if (targets == null) {
         targets = new ArrayList<Record>();
         connect.put(source, targets);
       }
       targets.add(getRecord(edge.target()));
     }
   }
   return connect;
 }
コード例 #3
0
ファイル: ColIO.java プロジェクト: iac-isabella/Groove
 private HostNode addNode(HostGraph result, String id) {
   HostNode node = result.getFactory().createNode(Integer.parseInt(id));
   result.addEdge(node, TypeLabel.createLabel(EdgeRole.FLAG, "i" + id), node);
   return node;
 }