com.gkutiel.github.flip.graph.Graph Maven / Gradle / Ivy
package com.gkutiel.github.flip.graph;
import java.util.UUID;
public class Graph {
private final Db db;
public Graph(final String path) {
db = new Db(path);
}
public Edge addEdge(final String v1, final String v2, final String label) {
db.addEdge(v1, v2, label);
return new Edge(v1, v2, label, db);
}
public Edge addEdge(final Vertex v1, final Vertex v2, final String label) {
return addEdge(v1.getId(), v2.getId(), label);
}
public Vertex addVertex() {
return addVertex(UUID.randomUUID().toString());
}
public Vertex addVertex(final String id) {
db.addVertex(id);
return new Vertex(id, db);
}
public void delEdge(final String v1, final String v2, final String label) {
db.delEdge(v1, v2, label);
}
public void delVertex(final String id) {
db.delVertex(id);
}
public Edge getEdge(final String v1, final String v2, final String label) {
return new Edge(v1, v2, label, db);
}
public Vertex getVertex(final String id) {
return new Vertex(id, db);
}
public Iterable getVertices() {
return db.getVertices();
}
}