Exemplo n.º 1
0
  public Nodes dual() {
    Graph graph = belongsTo();
    Nodes vertices = graph.nodes(Node.Duality.hvert);
    Nodes edges = graph.nodes(Node.Duality.hedge);

    return (this == vertices) ? edges : (this == edges) ? vertices : this;
  }
Exemplo n.º 2
0
  public Node.Duality duality() {
    Graph graph = belongsTo();
    Nodes vertices = graph.nodes(Node.Duality.hvert);
    Nodes edges = graph.nodes(Node.Duality.hedge);

    return (this == vertices)
        ? Node.Duality.hvert
        : (this == edges) ? Node.Duality.hedge : Node.Duality.hvert;
  }
Exemplo n.º 3
0
  public static String format(Graph graph) {
    Map<String, Object> map = new HashMap<String, Object>();
    map.put("type", graph.type());
    map.put("label", graph.label());
    map.put("families", graph.factory().families().toArray());

    if (graph.factory().contains(GraphFactory.Family.dual)) {
      map.put("nodes:hvert", graph.nodes(Node.Duality.hvert));
      map.put("hedge:hedge", graph.nodes(Node.Duality.hedge));

    } else {
      map.put("nodes", graph.nodes());
    }
    if (graph.factory().contains(GraphFactory.Family.fractal)) {
      map.put("up", graph.up());
    }
    return format(map);
  }