gremlin-python-tutorial API Documentation
draw
Created on 2023-05-15
@author: jv
GremlinDraw
helper class to draw Gremlin Graphs via Graphviz
Source code in gremlin/draw.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 |
|
__as_label(head, body)
create a label from head and body separated by a dash with the configured width
Source code in gremlin/draw.py
60 61 62 63 64 65 66 67 68 |
|
__init__(g, title, config=None)
constructor
Source code in gremlin/draw.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
|
draw_edge(edge, with_vertices=True)
draw a single given edge
Source code in gremlin/draw.py
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 |
|
draw_vertex(vertex)
draw a single given vertex
Source code in gremlin/draw.py
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
|
get_vertex_properties(vertex)
get the properties for a given vertex
Source code in gremlin/draw.py
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
|
show(g, title='Gremlin', v_limit=10, e_limit=10)
staticmethod
draw the given graph
Source code in gremlin/draw.py
227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 |
|
show_graph_traversal(g, gt, title='Gremlin')
staticmethod
draw the given graph traversal
Source code in gremlin/draw.py
243 244 245 246 247 248 249 250 251 252 |
|
GremlinDrawConfig
dataclass
draw configuration parameters
Source code in gremlin/draw.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
|
examples
Example
dataclass
Source code in gremlin/examples.py
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
|
download(path, force=False, debug=False)
load the graphml xml file from the given url and store it to the given file_name (prefix)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
url(str) |
the url to use |
required | |
file_name(str) |
the name of the file to load |
required | |
force(bool) |
if True overwrite |
required | |
debug(bool) |
if True show debugging information |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
the filename loaded |
Source code in gremlin/examples.py
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
|
load(g, volume, force=False, debug=False)
download graph from remote_path to local_path depending on force flag and load graph into g
Parameters:
Name | Type | Description | Default |
---|---|---|---|
g(GraphTraversalSource) |
the target graph (inout) |
required | |
volume |
Volume
|
Volume |
required |
force(bool) |
if True download even if local copy already exists |
required | |
debug(bool) |
if True show debugging information |
required |
Source code in gremlin/examples.py
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
|
Examples
Examples
Source code in gremlin/examples.py
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 |
|
__init__(volume, debug=False)
Constructor
Parameters:
Name | Type | Description | Default |
---|---|---|---|
volume |
Volume
|
Volume |
required |
debug(bool) |
if true switch on debugging |
required |
Source code in gremlin/examples.py
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
|
load_by_name(g, name)
load an example by name to the given graph
Parameters:
Name | Type | Description | Default |
---|---|---|---|
g(GraphTraversalSource) |
the target graph (inout) |
required | |
name(str) |
the name of the example |
required |
Raises:
Type | Description |
---|---|
Exception
|
if the example does not exist |
Source code in gremlin/examples.py
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 |
|
Volume
dataclass
map a local path on the client to a remote path on a server e.g. when using a Volume in a docker container
Source code in gremlin/examples.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
|
docker()
staticmethod
get the default docker volume mapping
Returns:
Name | Type | Description |
---|---|---|
Volume |
Volume
|
the local_path/remote_path mapping |
Source code in gremlin/examples.py
47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
|
local()
staticmethod
get the default local volume mapping
Returns:
Name | Type | Description |
---|---|---|
Volume |
Volume
|
the local_path/remote_path mapping |
Source code in gremlin/examples.py
62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
|
remote(file_name)
return the remote mapping of the given file_name
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file_name(str) |
the file name to map |
required |
Returns: str: the remote path
Source code in gremlin/examples.py
35 36 37 38 39 40 41 42 43 44 45 |
|
remote
Created on 2019-09-17
@author: wf
RemoteTraversal
helper class for Apache Tinkerpop Gremlin Python GLV remote access
Source code in gremlin/remote.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
|
__init__(server, in_jupyter=False)
constructor
Source code in gremlin/remote.py
27 28 29 30 31 32 33 |
|
clear(g)
staticmethod
clear the given graph
Source code in gremlin/remote.py
95 96 97 98 99 100 |
|
close()
close my connection
Source code in gremlin/remote.py
77 78 79 80 81 |
|
fromYaml(serverName='server', config_path=None, in_jupyter=False)
staticmethod
create a server from the given yaml file
Parameters:
Name | Type | Description | Default |
---|---|---|---|
serverName(str) |
the servername to use |
required | |
config_path(str) |
the path to the server configuration file |
required |
Source code in gremlin/remote.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
|
g()
get the graph traversal source
Returns:
Type | Description |
---|---|
GraphTraversalSource
|
the graph traversal source |
Source code in gremlin/remote.py
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
|
load(g, graphmlFile)
staticmethod
load the given graph from the given graphmlFile
Source code in gremlin/remote.py
83 84 85 86 87 88 89 90 91 92 93 |
|
Server
Server description
Source code in gremlin/remote.py
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 |
|
__init__(host='localhost', port=8182, alias='g', name='TinkerGraph', username='', password='', debug=False, helpUrl='http://wiki.bitplan.com/index.php/Gremlin_python#Connecting_to_Gremlin_enabled_graph_databases')
constructor
Parameters:
Name | Type | Description | Default |
---|---|---|---|
host(str) |
the host to connect to |
required | |
port(int) |
the port to connect to |
required | |
alias(str) |
the alias to use |
required | |
name(str) |
the name of the server |
required | |
username(Optional[str]) |
the username to use |
required | |
password(Optional[str]) |
the password to use |
required | |
debug(bool) |
True if debug output should be generated |
required | |
helpUrl(str) |
the help url to use |
required |
Source code in gremlin/remote.py
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 |
|
check_socket()
check my socket
Returns:
Type | Description |
---|---|
bool
|
True if socket is open |
Source code in gremlin/remote.py
144 145 146 147 148 149 150 151 152 153 |
|
read(name, config_path=None)
staticmethod
read me from a yaml file
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name(str) |
the name of the server |
required | |
config_path(str) |
the path to the config files |
required |
Returns:
Type | Description |
---|---|
'Server'
|
the server |
Raises:
Type | Description |
---|---|
Exception
|
if the yaml file is missing |
Source code in gremlin/remote.py
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
|
write()
write me to my yaml file
Source code in gremlin/remote.py
191 192 193 194 195 196 197 198 199 |
|