@Override
public Relation add(Identifiable source, final String type, Identifiable target) {
Transaction tx = graph.beginTx();
try {
Node root =graph.getNodeById(0);
String sourceTypeName = source.getClass().getSimpleName();
String targetTypeName = target.getClass().getSimpleName();
Node sourceTypeNode = getOrCreateNodeType(sourceTypeName);
Node targetTypeNode = getOrCreateNodeType(targetTypeName);
getOrCreateRelationship(root, sourceTypeNode, Named.relation(sourceTypeName));
getOrCreateRelationship(root, targetTypeNode, Named.relation(targetTypeName));
Node sourceNode = getOrCreateNode(source, sourceTypeName);
getOrCreateRelationship(sourceTypeNode, sourceNode, Named.relation(REL_TYPE_ALL));
Node targetNode = getOrCreateNode(target, targetTypeName);
getOrCreateRelationship(targetTypeNode, targetNode, Named.relation(REL_TYPE_ALL));
getOrCreateRelationship(sourceNode, targetNode, Named.relation(type));
tx.success();