コード例 #1
0
def test_input_graph():
    temp_titan_graph = TitanFactory.build().set("storage.backend", "inmemory").open()
    temp_g = Gremthon(temp_titan_graph)
    temp_g.input_graph(graph_son_filename)
    assert temp_g.V.count() == 2
コード例 #2
0
import os
from gremthon import Gremthon
example_graph_son = '{}/doctors-consumers-graph.json'.format(os.environ['TEST_DRIVE_DIR'])
g = Gremthon(rexster.getGraph("graph"))
count = g.V.count()
if count == 0:
    g.input_graph(example_graph_son)
コード例 #3
0
def test_input_graph():
    temp_titan_graph = TitanFactory.build().set('storage.backend','inmemory').open()
    temp_g = Gremthon(temp_titan_graph)
    temp_g.input_graph(graph_son_filename)
    assert temp_g.V.count() == 2
コード例 #4
0
# Test scenarios based on http://gremlindocs.com/

from gremthon import Gremthon
from itertools import groupby
import sys

#Java imports
from com.tinkerpop.blueprints.impls.tg import TinkerGraphFactory
from java.util import ArrayList
from java.lang import Float

graph = TinkerGraphFactory.createTinkerGraph()
g = Gremthon(graph)

youngest = sys.maxsize


def test_both():
    assert set([v.id for v in g.v(4).both()]) == {'1', '5', '3'}
    assert [v.id for v in g.v(4).both('knows')] == ['1']
    assert set([v.id
                for v in g.v(4).both('knows', 'created')]) == {'1', '5', '3'}
    assert [v.id for v in g.v(4).both(1, 'knows', 'created')] == ['1']


def test_both_e():
    assert set([e.id for e in g.v(4).both_e()]) == {'8', '10', '11'}
    assert [e.id for e in g.v(4).both_e('knows')] == ['8']
    assert set([e.id for e in g.v(4).both_e('knows', 'created')
                ]) == {'8', '10', '11'}
    assert [e.id for e in g.v(4).both_e(1, 'knows', 'created')] == ['8']
コード例 #5
0
from com.thinkaurelius.titan.graphdb.types import StandardPropertyKeyMaker
from com.thinkaurelius.titan.graphdb.types.vertices import EdgeLabelVertex
from com.thinkaurelius.titan.graphdb.types import StandardEdgeLabelMaker
from com.thinkaurelius.titan.graphdb.types import VertexLabelVertex
from com.thinkaurelius.titan.graphdb.types import StandardVertexLabelMaker
from com.thinkaurelius.titan.core import Cardinality
from java.lang import Double, String, Integer
from java.nio.file import Files


graph_son_filename = os.path.join(str(Files.createTempDirectory('temp_graph_son_dir')), 'graph.son')

graph = TinkerGraphFactory.createTinkerGraph()
titan_graph = TitanFactory.build().set('storage.backend','inmemory').open()

g = Gremthon(graph)
tg = Gremthon(titan_graph)


def test_gremthon_repr():
    """
        Verify repr of a gremthon wrapped graph
    """
    assert str(g) == 'tinkergraph[vertices:6 edges:6]'


def test_gremthon_titan_repr():
    """
        Verify repr of a gremthon wrapped titan graph
    """
    assert str(tg) == 'titangraph[inmemory:[127.0.0.1]]'