Package graphmatcher.graph

Examples of graphmatcher.graph.Graph


  public void initListeners() {
    patternListPanel.addListSelectionListener(new ListSelectionListener() {
      public void valueChanged(ListSelectionEvent e) {
        JList list = (JList) e.getSource();
        Graph graph = (Graph) list.getSelectedValue();
        patternGraphPanel.setGraph(graph);
      }
    });

    templateListPanel.addListSelectionListener(new ListSelectionListener() {
      public void valueChanged(ListSelectionEvent e) {
        JList list = (JList) e.getSource();
        Graph graph = (Graph) list.getSelectedValue();
        templateGraphPanel.setGraph(graph);
      }
    });
  }
View Full Code Here


    frame.add(graphPanel, BorderLayout.CENTER);

    listPanel.addListSelectionListener(new ListSelectionListener() {
      public void valueChanged(ListSelectionEvent e) {
        JList list = (JList) e.getSource();
        Graph graph = (Graph) list.getSelectedValue();
        graphPanel.setGraph(graph);
      }
    });

    frame.pack();
View Full Code Here

  }

  private void initActions() {
    matchButton.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent arg0) {
        Graph pattern = _inputPanel.getPatternGraph();
        // AffineTransform at = new AffineTransform();
        // at.rotate(Math.toRadians(180));
        // GraphTools.transformGraph(pattern, at);

        Graph template = _inputPanel.getTemplateGraph();

        String matcherID = optionPanel.getSelectedMatcherID();
        AbstractMatcher matcher = MatcherFactory.createMatcher(matcherID, pattern, template);
        MatchingResult matchingResult = matcher.match(optionPanel.getMatchingOptions());
        _matchingPanel.setOptions(_guiOptionPanel.showMatchingEdges(), _guiOptionPanel.showIndices(),
View Full Code Here

    int returnVal = chooser.showOpenDialog(parent);

    if (returnVal == JFileChooser.APPROVE_OPTION) {
      File[] files = chooser.getSelectedFiles();
      Graph g;

      for (int i = 0; i < files.length; i++) {
        try {
          g = new Graph(files[i]);
          graphs.add(g);
        } catch (Exception e) {
          e.printStackTrace();
        }
      }
View Full Code Here

  public static Graph loadGraph(String dir, String name) {
    String path = workingDir.getAbsolutePath() + "\\" + dir + "\\" + name + ".graph";
    System.out.println(path);
    File file = new File(path);
    Graph result;
    try {
      result = new Graph(file);
    } catch (NumberFormatException e) {
      e.printStackTrace();
      return null;
    } catch (IOException e) {
      e.printStackTrace();
View Full Code Here

        File graphFile = files[i];
        if (counter >= numberOfGraphs) {
          break;
        }
        try {
          Graph graph = new Graph(graphFile);
          result.add(graph);
        } catch (NumberFormatException e) {
          e.printStackTrace();
        } catch (IOException e) {
          e.printStackTrace();
View Full Code Here

      while (vertex1 == vertex2) {
        vertex2 = random.nextInt(numberOfVertices);
      }
      edges[i] = new Edge(vertex1, vertex2);
    }
    return new Graph(vertices, edges);
  }
View Full Code Here

      long currentUsedTime = 0;
      for (int i = 0; i < patternGraphList.size(); i++) {
        if (stopThread) {
          break;
        }
        Graph pattern = patternGraphList.get(i);
        double rotation = Double.parseDouble(patternRotationTextField.getText());
        if (rotation != 0) {
          System.out.println("rotiere Graph " + pattern.getName() + " um " + rotation + "�");
          GraphTools.transformGraph(pattern, GraphTools.createRotation(rotation));
        }

        model.addRow(new Vector<String>());
        model.setValueAt(pattern.toString(), rowIndex, 0);

        _usedTime += matchHelper(pattern, templateGraphList, rowIndex, matcherOptions,
            matcherContainer);
        currentUsedTime = 2 * _usedTime;

 
View Full Code Here

      ExecutorService executorService = Executors.newFixedThreadPool(Runtime.getRuntime()
          .availableProcessors());
      progressBar.setValue(0);
      for (int j = 0; j < graphList.size(); j++) {
        final int currentJ = j;
        Graph template = graphList.get(j);
        if (pattern.getName().equals(template.getName())) {
          continue;
        }

        final AbstractMatcher matcher = MatcherFactory.createMatcher(options.getMatcherID(), pattern,
            template);
        Runnable matchingTask = new Runnable() {
          @Override
          public void run() {
            try {
              MatchingResult matchingResult = matcher.match(options);
              matchingResults[currentJ] = matchingResult;

              synchronized (progressBar) {
                progressBar.setValue(progressBar.getValue() + 1);
              }
            } catch (Exception e) {
              e.printStackTrace();
            }
          }
        };

        executorService.submit(matchingTask);
      }
      try {
        executorService.shutdown();
        executorService.awaitTermination(1, TimeUnit.DAYS);
      } catch (InterruptedException e) {
        e.printStackTrace();
      }

      Arrays.sort(matchingResults, new Comparator<MatchingResult>() {
        @Override
        public int compare(MatchingResult o1, MatchingResult o2) {
          if (o1 == null) {
            return 1;
          }
          if (o2 == null) {
            return -1;
          }
          if (o1.getQuality() > o2.getQuality()) {
            return -1;
          } else {
            return 1;
          }
        }
      });

      NumberFormat format = NumberFormat.getInstance();
      format.setMinimumFractionDigits(2);
      format.setMaximumFractionDigits(2);
      System.out.println("Matching Qualities: " + pattern.getName());

      boolean bestTemplateIsCorrect = pattern.equalMeaning(matchingResults[0].getTemplate());
      if (bestTemplateIsCorrect) {
        bestPositive++;
      }
      int tp = 0, tn = 0, fp = 0, fn = 0;

      boolean firstNegativeFound = false;
      for (int i = 0; i < matchingResults.length; i++) {
        if (matchingResults[i] == null) {
          continue;
        }
        Graph template = matchingResults[i].getTemplate();
        double quality = matchingResults[i].getQuality();
        boolean equal = pattern.equalMeaning(template);
        if (!equal) {
          firstNegativeFound = true;
        }
View Full Code Here

TOP

Related Classes of graphmatcher.graph.Graph

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.