use of com.tinkerpop.blueprints.impls.tg.TinkerGraph in project frames by tinkerpop.
the class FramedGraphTest method generateGraph.
public Graph generateGraph() {
final TinkerGraph baseGraph = new TinkerGraph();
baseGraph.getFeatures().isPersistent = false;
return new FramedGraph<TinkerGraph>(baseGraph);
}
use of com.tinkerpop.blueprints.impls.tg.TinkerGraph in project frames by tinkerpop.
the class FramedGraphTest method testCreateFrame.
public void testCreateFrame() {
Graph graph = new TinkerGraph();
FramedGraph<Graph> framedGraph = new FramedGraphFactory().create(graph);
Person person = framedGraph.addVertex(null, Person.class);
assertEquals(person.asVertex(), graph.getVertices().iterator().next());
int counter = 0;
for (Vertex v : graph.getVertices()) {
counter++;
}
assertEquals(counter, 1);
counter = 0;
for (Edge e : graph.getEdges()) {
counter++;
}
assertEquals(counter, 0);
Person person2 = framedGraph.addVertex("aPerson", Person.class);
assertEquals(person2.asVertex().getId(), "aPerson");
counter = 0;
for (Vertex v : graph.getVertices()) {
counter++;
}
assertEquals(counter, 2);
}
use of com.tinkerpop.blueprints.impls.tg.TinkerGraph in project hale by halestudio.
the class GraphMLDialog method open.
/**
* Opens the dialog for displaying the graph
*
* @throws IOException may be thrown if the graph string from the database
* can fails to convert
*/
public void open() throws IOException {
Shell parent = super.getParent();
final Shell shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.MIN | SWT.MODELESS);
shell.setFocus();
shell.addFocusListener(new FocusListener() {
@Override
public void focusLost(FocusEvent e) {
shell.setMinimized(true);
}
@Override
public void focusGained(FocusEvent e) {
// ignore
}
});
shell.setLayout(GridLayoutFactory.fillDefaults().create());
shell.setText(getText());
final Composite viewerContainer = new Composite(shell, SWT.EMBEDDED);
viewerContainer.setLayout(new FillLayout());
viewerContainer.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
TinkerGraph tgraph = new TinkerGraph();
GraphMLReader greader = new GraphMLReader(tgraph);
ByteArrayInputStream in;
in = new ByteArrayInputStream(graphString.getBytes(("UTF-8")));
greader.inputGraph(in);
GraphViewer viewer = new GraphViewer(viewerContainer, SWT.NONE);
TreeLayoutAlgorithm la = new TreeLayoutAlgorithm(TreeLayoutAlgorithm.RIGHT_LEFT);
viewer.setLabelProvider(new GraphMLLabelProvider());
viewer.setContentProvider(new GraphMLContentProvider());
viewer.setInput(tgraph.getEdges());
viewer.setLayoutAlgorithm(la, true);
viewer.applyLayout();
viewerContainer.pack();
viewerContainer.setVisible(true);
shell.open();
Display display = parent.getDisplay();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
}
use of com.tinkerpop.blueprints.impls.tg.TinkerGraph in project hale by halestudio.
the class TreeGraphMLProvider method generateGraph.
/**
* @see eu.esdihumboldt.hale.ui.cst.debug.metadata.internal.TreeGraphProvider#generateGraph()
*/
@Override
public Graph generateGraph() {
tree.accept(graphVisitor);
SetMultimap<String, String> connections = graphVisitor.getAllConnections();
Set<String> ids = graphVisitor.getAllIds();
TinkerGraph graph = new TinkerGraph();
// add nodes to the graph
for (String key : ids) {
TransformationNode node = graphVisitor.getNode(key);
Vertex vertex = graph.addVertex(key);
setVertexProperty(node, vertex);
}
for (String key : connections.keySet()) {
for (String value : connections.get(key)) {
graph.addEdge(null, graph.getVertex(key), graph.getVertex(value), " ");
}
}
return graph;
}
use of com.tinkerpop.blueprints.impls.tg.TinkerGraph in project pentaho-metaverse by pentaho.
the class LineageClientIT method setUp.
@Before
public void setUp() throws Exception {
transMeta = new TransMeta(MERGE_JOIN_KTR_FILENAME);
IDocument doc = MetaverseUtil.createDocument(new Namespace("SPOON"), transMeta, transMeta.getFilename(), transMeta.getName(), "ktr", URLConnection.getFileNameMap().getContentTypeFor(transMeta.getFilename()));
Graph graph = new TinkerGraph();
MetaverseUtil.addLineageGraph(doc, graph);
}
Aggregations