Package graphmatcher.graph

Examples of graphmatcher.graph.Vertex


  protected int[] getMatching() {
    int[] matching = new int[pattern.getNumberOfVertices()];
    Point patternCenter = pattern.getCenter();
    Point templateCenter = template.getCenter();
    for (int i = 0; i < pattern.getNumberOfVertices(); i++) {
      Vertex patternVertex = pattern.vertices()[i];
      Point patternVertexPoint = new Point(patternVertex.x - patternCenter.x, patternVertex.y
          - patternCenter.y);
      int bestTemplateVertexID = -1;
      double minDist = Double.MAX_VALUE;
      for (int j = 0; j < template.getNumberOfVertices(); j++) {
        Vertex templateVertex = template.vertices()[j];
        Point templateVertexPoint = new Point(templateVertex.x - templateCenter.x, templateVertex.y
            - templateCenter.y);
        double dist = DistanceHelper.getDistance(patternVertexPoint, templateVertexPoint);
        if (dist < minDist) {
          minDist = dist;
View Full Code Here


    // g.fillOval(center.x + offset.x, -center.y + offset.y, 4, 4);

    // Knoten mit Nummer zeichnen
    g.setColor(Color.BLACK);
    for (int i = 0; i < graph.vertices().length; i++) {
      Vertex vertex = graph.vertices()[i];
      int x = vertex.x + offset.x;
      int y = -vertex.y + offset.y;
      g.drawOval(x, y, 1, 1);
      if (showIndices) {
        g.drawString("" + i, x + 2, y + 2);
View Full Code Here

    gr.setColor(edgeColor);
    for (int i = 0; i < g.edges().length; i++) {
      Edge e = g.edges()[i];

      Vertex p = g.vertices()[e.vertex1];
      Vertex q = g.vertices()[e.vertex2];
      gr.drawLine(p.x, -p.y, q.x, -q.y);
      // gr.drawLine(p.iX, d.height - p.iY, q.iX, d.height - q.iY);
    }

    for (int i = 0; i < g.vertices().length; i++) {
      Vertex v = g.vertices()[i];
      // System.out.println(v.iX+"-"+v.iY+" <-> "+d+" - "+ratio);
      gr.setColor(nodeColor);
      int x = v.x;
      int y = v.y;
      // System.out.println(x+"-"+y);
View Full Code Here

public class NeighbourHelper {
 
  public static int[] getNeighbours(int vertexId, final Graph graph) {
    Integer[] vertices = new Integer[graph.vertices().length-1];
    final Vertex vertex = graph.vertices()[vertexId];
    int index=0;
    boolean foundVertex = false;
    for (int i=0; i < graph.vertices().length; i++) {
      if (i==vertexId) {
        continue;
      }
//      if (!vertex.equals(graph.vertices()[i])) {
        vertices[index++]=i;
//      } else {
//        if (foundVertex) {
//          throw new RuntimeException("ung�ltiger Graph: doppelter Knoten");
//        }
//        foundVertex=true;
//      }
    }
    Arrays.sort(vertices, new Comparator<Integer>(){
      public int compare(Integer o1, Integer o2) {
        Vertex v1 = graph.vertices()[o1.intValue()];
        Vertex v2 = graph.vertices()[o2.intValue()];
        double dist1 = Vertex.getDistanceTo(vertex, v1);
        double dist2 = Vertex.getDistanceTo(vertex, v2);
        if (dist1 < dist2) {
          return -1;
        } else if (dist1 > dist2) {
View Full Code Here

    _numberOfNeighbours = numberOfNeighbours;
    this.matchingOptions = matchingOptions;
    _numberOfAngleBins = matchingOptions.numberOfAngleBins;
    _numberOfRadiusBins = matchingOptions.numberOfRadiusBins;
    _vertexId = vertexId;
    Vertex vertex = graph.vertices()[vertexId];
    _graph = graph;

    _center = graph.getCenter();
    _maxDistance = graph.getMaximumVertexDistanceToCenter() * 2;
    double distToCenter = DistanceHelper.getDistance(_center, vertex.toPoint());
    _relativDist = distToCenter / _maxDistance;

    _unconnectedVerticesBins = new Vector[_numberOfAngleBins][_numberOfRadiusBins];
    _connectedVerticesBins = new Vector[_numberOfAngleBins][_numberOfRadiusBins];
    _visibleVerticesBins = new Vector[_numberOfAngleBins][_numberOfRadiusBins];
View Full Code Here

    distributeNeighboursInBins();
  }

  private void distributeNeighboursInBins() {
    // logger.info("Ermittele ShapeContext von Knoten " + _vertexId);
    Vertex vertex = _graph.vertices()[_vertexId];
    Point vertexPoint = new Point(vertex.x, vertex.y);
    int[] neighbourIds = NeighbourHelper.getNeighbours(_vertexId, _graph);
    for (int i = 0; i < _numberOfNeighbours; i++) {
      // for (int i = neighbourIds.length-1; i > neighbourIds.length -
      // Options.numberOfNeighbours; i--) {
      int neighbourId = neighbourIds[i];
      Vertex neighbour = _graph.vertices()[neighbourId];
      Point neighbourPoint = new Point(neighbour.x, neighbour.y);

      if (matchingOptions.isNoRotation()) {
        _center = new Point(vertexPoint.x + 1, vertexPoint.y);
      }
View Full Code Here

  public static double getDistance(Vertex vertex1, Vertex vertex2) {
    return getDistance(vertex1.toPoint(), vertex2.toPoint());
  }

  public static double getLength(Edge edge, Graph graph) {
    Vertex vertex1 = graph.vertices()[edge.vertex1];
    Vertex vertex2 = graph.vertices()[edge.vertex2];
    return getDistance(vertex1, vertex2);
  }
View Full Code Here

    return getDistance(vertex1, vertex2);
  }

  public static double getDistanceToCenter(Edge edge, Graph graph) {
    double distance = 0;
    Vertex vertex1 = graph.vertices()[edge.vertex1];
    Vertex vertex2 = graph.vertices()[edge.vertex2];
    distance += getDistance(vertex1.toPoint(), graph.getCenter());
    distance += getDistance(vertex2.toPoint(), graph.getCenter());
    return distance / 2;
  }
View Full Code Here

    Random random = new Random();
    Vertex[] vertices = new Vertex[numberOfVertices];
    for (int i = 0; i < vertices.length; i++) {
      int x = random.nextInt(550);
      int y = random.nextInt(350);
      vertices[i] = new Vertex(x, y);
    }
    Edge[] edges = new Edge[numberOfEdges];
    for (int i = 0; i < edges.length; i++) {
      int vertex1 = random.nextInt(numberOfVertices);
      int vertex2 = vertex1;
View Full Code Here

  }

  public static void transformGraph(Graph graph, AffineTransform affineTransform) {
    for (int i = 0; i < graph.vertices().length; i++) {
      Vertex vertex = graph.vertices()[i];
      double[] point = new double[2];
      point[0] = vertex.x;
      point[1] = vertex.y;
      double[] newPoint = new double[2];
      affineTransform.transform(point, 0, newPoint, 0, 1);
View Full Code Here

TOP

Related Classes of graphmatcher.graph.Vertex

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.