1
0
Fork 0

Merge branch 'devel' of https://github.com/triAGENS/ArangoDB into devel

This commit is contained in:
Jan Steemann 2014-06-17 11:26:31 +02:00
commit d2bc429a1a
7 changed files with 148 additions and 270 deletions

View File

@ -2,6 +2,16 @@
Write Intro!
!SECTION Get vertices from edges.
!SUBSECTION Get vertex *from* of an edge
<!-- @startDocuBlock JSF_general_graph_getFromVertex -->
!SUBSECTION Get vertex *to* of an edge
<!-- @startDocuBlock JSF_general_graph_getToVertex -->
!SECTION Some Methods
```javascript

View File

@ -1,8 +1,10 @@
!SECTION Create a graph
!CHAPTER Graph Management
<!-- @startDocuBlock JSF_general_graph_create -->
There are different types of edge definitions:
In order to create a graph the philosophy of handling the graph content has to introduced.
A graph contains a set of edge definitions each referring to one edge collection and
defining constraints on the vertex collections used as start and end points of the edges.
Furthermore a graph can contain an arbitrary amount of vertex collections, called orphan collections, that are not used in any edge definition but should be managed by the graph.
In order to create a graph the functionality to create edge definitions has to be introduced first:
!SECTION Edge Definitions
@ -24,6 +26,31 @@ The edge definitions for a graph is an Array containing arbitrary many directed
<!-- @startDocuBlock JSF_general_graph_directedRelationDefinition -->
!SUBSECTION Orphan Collections
Each graph has an orphan collection. It consists of arbitrary many vertex collection (type *document*), that are not
used in an edge definition of the graph. If the graph is extended with an edge definition using one of the orphans,
it will be removed from the orphan collection automatically.
!SUBSUBSECTION Add
<!-- @startDocuBlock JSF_general_graph__addOrphanCollection -->
!SUBSUBSECTION Read
<!-- @startDocuBlock JSF_general_graph__getOrphanCollections -->
!SUBSUBSECTION Remove
<!-- @startDocuBlock JSF_general_graph__removeOrphanCollection -->
!SECTION Create a graph
After having introduced edge definitions and orphan collections a graph can be created.
<!-- @startDocuBlock JSF_general_graph_create -->
!SUBSUBSECTION Complete Example to create a graph
Example Call:
@ -53,49 +80,29 @@ alternative call:
_key: "123"
};
```
!SUBSECTION Orphan Collections
Each graph has an orphan collection. It consists of arbitrary many vertex collection (type *document*), that are not
used in an edge definition of the graph. If the graph is extended with an edge definition using one of the orphans,
it will be removed from the orphan collection automatically.
!SUBSECTION List available graphs
!SUBSUBSECTION Add
<!-- @startDocuBlock JSF_general_graph_list_call -->
`general-graph._list()` *List all graphs.*
<br />
<br />
<!-- @startDocuBlock JSF_general_graph__addOrphanCollection -->
<!-- @startDocuBlock JSF_general_graph_list_info -->
!SUBSUBSECTION Read
<br />
@EXAMPLES
<br />
<!-- @startDocuBlock JSF_general_graph__getOrphanCollections -->
<!-- @startDocuBlock JSF_general_graph_list_examples -->
!SUBSUBSECTION Remove
!SUBSECTION Load a graph
<!-- @startDocuBlock JSF_general_graph__removeOrphanCollection -->
!SUBSECTION Read a graph
```js
> var graph = require("org/arangodb/graph");
> var g = graph._graph("myStore");
```
- - -
<!-- @startDocuBlock JSF_general_graph_graph -->
!SUBSECTION Remove a graph
Removes a graph from the collection *\_graphs*.
```js
> graph._drop(graphId, dropCollections);
true
```
graphId: string - id of the graph to be removed
dropCollections: bool - optional. *true* all collections of the graph will be deleted.
*false* no collection of the graph will be deleted. Default: *true*
<!-- @startDocuBlock JSF_general_graph_drop -->
!SECTION Edge
@ -132,226 +139,3 @@ dropCollections: bool - optional. *true* all collections of the graph will be de
!SUBSECTION Remove
<!-- @startDocuBlock JSF_general_graph_edge_collection_remove -->
!SECTION Vertices
!SUBSECTION Get vertex *from* of an edge
<!-- @startDocuBlock JSF_general_graph_getFromVertex -->
!SUBSECTION Get vertex *to* of an edge
<!-- @startDocuBlock JSF_general_graph_getToVertex -->
!SECTION Some Methods
```javascript
graph.listCommonNeighbors(vertex1, vertex2, options)
```
vertex1: string - vertex id
vertex2: string - vertex id
options:
* see getNeighbors
```javascript
graph.amountCommonNeighbors(vertex1, vertex2, options)
```
vertex1: string - vertex id
vertex2: string - vertex id
options:
* see getNeighbors
```javascript
graph.listCommonProperties((vertex1, vertex2)
```
vertex1: string - vertex id
vertex2: string - vertex id
```javascript
graph.amountCommonProperties((vertex1, vertex2)
```
vertex1: string - vertex id
vertex2: string - vertex id
```javascript
graph.pathTo(vertex1, vertex2, options)
```
vertex1: string - vertex id
vertex2: string - vertex id
options: see determinePredecessors
```javascript
graph.distanceTo(vertex1, vertex2, options)
```
vertex1: string - vertex id
vertex2: string - vertex id
options: see determinePredecessors
```javascript
graph.determinePredecessors(vertex1, source, options)
```
vertex1: string - vertex id
source: ???
options:
* cached: Boolean -> If true a cached version will be used
```javascript
graph.pathesForTree(vertex1, tree, path_to_here)
```
vertex1: string - vertex id
tree: ???
path_to_here: Internal Array, should initially be undefined or an empty array
```javascript
graph.getNeighbors(vertex1, options)
```
vertex1: string - vertex id
options:
* direction:
"inbound" -> consider only inbound edges
"outbount" -> consider only outbound edges
"any"(default) -> consider both directions
* weight: attribute-name -> use this attribute to determine edgeweight
* weight_function: function -> use this function to calculate the weight
* default-weight -> us this value if weight could not be calculated otherwise, default is Infinity
* only: function -> will be invoked on any edge, neighbors will only be included if this returns true or is not defined.
```javascript
graph.measurement(vertex1, measurement)
```
vertex1: string - vertex id
measurement: String
* "eccentricity": Calculates the eccentricity of the vertex
* "betweenness": Calculates the betweenness of the vertex
* "closeness": Calculates the closeness of the vertex
!SECTION Using Graphs in AQL {#JSModuleGraphAQL}
Complete Documentation can be copied from normal AQL documentation, with:
* replace VertexCollection/EdgeCollection by Graph
!SUBSECTION PATHS
* **BUILD ON** `ahuacatl.js`: 4090 `GRAPH_PATHS` -> uses `COLLECTION` on second arg, has to use `COLLECTION` or `GRAPH` accordingly. Has to pass the graph to traverser
Paths returns a handle for all paths included in the graph:
`GRAPH_PATHS(graphname, direction, followcycles)`
* `graphname` defines the graph
* `direction` defines the direction
* `followcycles` defines if cyclic paths should be followed
Example calls:
```javascript
FOR p in PATHS(shop, "outbound")
FILTER p.source._id == "123456/123456" && LENGTH(p.edges) == 2
RETURN p.vertices[*].name
```
!SUBSECTION TRAVERSAL
`GRAPH_TRAVERSAL(graphname, startVertex, direction, options)}`
* **BUILD ON** `ahuacatl.js`: 4243 `TRAVERSAL_FUNC` -> uses `COLLECTION` on first and second arg, has to use `COLLECTION` or `GRAPH` accordingly. Has to pass the graph to traverser
* **TO CHANGE** `common/modules/org/arangodb/graph/traversal.js`: 106 `collectionDatasourceFactory` should be able to work on Graphs
Traverses the graph described by the `graphname`,
starting at the vertex identified by id `startVertex`. Vertex connectivity is
specified by the `direction` parameter:
- `"outbound"`: Vertices are connected in `_from` to `_to` order
- `"inbound"`: Vertices are connected in `_to` to `_from` order
- `"any"`: Vertices are connected in both `_to` to `_from` and in
`_from` to `_to` order
All this is defined already for TRAVERSAL, no changes should be applied here
```javascript
TRAVERSAL(shop, "products/arangodb", "outbound", {
strategy: "depthfirst",
order: "postorder",
itemOrder: "backward",
maxDepth: 6,
paths: true
})
```
!SUBSECTION TRAVERSAL_TREES
`GRAPH_TRAVERSAL_TREE(graphname, startVertex, direction, connectName, options)`
* **BUILD ON** `ahuacatl.js`: 4243 `TRAVERSAL_FUNC` -> uses `COLLECTION` on first and second arg, has to use `COLLECTION` or `GRAPH` accordingly. Has to pass the graph to traverser
* **TO CHANGE** `common/modules/org/arangodb/graph/traversal.js`: 106 `collectionDatasourceFactory` should be able to work on Graphs
```javascript
GRAPH_TRAVERSAL_TREE(shop, "products/arangodb", "inbound", "sold", {
itemOrder: "forward"
})
```
Makes internal use of TRAVERSAL, modyfing that is sufficient.
!SUBSECTION SHORTEST_PATHS
* **BUILD ON** `ahuacatl.js`: 4243 `TRAVERSAL_FUNC` -> uses `COLLECTION` on first and second arg, has to use `COLLECTION` or `GRAPH` accordingly. Has to pass the graph to traverser
* **TO CHANGE** `common/modules/org/arangodb/graph/traversal.js`: 106 `collectionDatasourceFactory` should be able to work on Graphs
`GRAPH_SHORTEST_PATH(graphname, startVertex, endVertex, direction, options)`:
Equal to functionality of `SHORTEST_PATH`.
Makes internal use of TRAVERSAL, modyfing that is sufficient.
!SUBSECTION EDGES
* **BUILD ON** `ahuacatl.js`: 4479 `GRAPH_EDGES` -> uses `COLLECTION` on first argument, has to use `COLLECTION` or `GRAPH` accordingly.
`GRAPH_EDGES(graphname, startvertex, direction, edgeexamples, collectionRestrictions)`
Same as original, but with optional `collectionRestrictions`to define which edge collections have to be included. Default is all.
!SUBSECTION NEIGHBORS
* **BUILD ON** `ahuacatl.js`: 4508 `GRAPH_NEIGHBORS` -> uses `COLLECTION` on first, has to use `COLLECTION` or `GRAPH` accordingly.
`GRAPH_NEIGHBORS(graphname, startvertex, direction, edgeexamples)`
* Each of the graph functions in AQL (`PATHS`, `TRAVERSAL`, `TRAVERSAL_TREES`, `SHORTEST_PATHS`, `EDGES`, `NEIGHBORS`) will take the graph as its first argument (which parts of the other arguments will be pushed to be defined in FILTER and not in the signature of the function was discussed, but postponed because it is a detail).

View File

@ -7,3 +7,6 @@ You can find packages for various operation systems at our [download](http://www
If you don't want to install ArangoDB at the beginning and just want to experiment with the features, you can use our [online demo](https://www.arangodb.org/tryitout).
In this Chapter you will also learn how to Compile ArangoDB from scratch.
You also get help if you want to update your ArangoDB Version to the newest one!

View File

@ -5,6 +5,8 @@
* [Mac OS X](Installing/MacOSX.md)
* [Windows](Installing/Windows.md)
* [Compiling](Installing/Compiling.md)
* [Upgrading in general](Installing/Upgrading.md)
* [Set up Cluster](Installing/Cluster.md)
<!-- 2 -->
* [First Steps](FirstSteps/README.md)
* [Getting Familiar](FirstSteps/GettingFamiliar.md)

View File

@ -28,6 +28,9 @@
<li>
<a href="{{ options.links.issues|default(githubHost+githubId+"/issues") }}" target="blank"class="issues-link">Have any questions?</a>
</li>
<li>
<a href="https://www.arangodb.org/manuals/2/NewFeatures21.html" target="_blank">Whats New in this Version?</a>
</li>
{% endif %}
{% if _divider %}
<li class="divider"></li>

View File

@ -60,8 +60,7 @@ def fetch_comments(dirpath):
if ("@startDocuBlock" in _text) or \
("@endDocuBlock" in _text):
fh.write("<!-- %s -->\n\n" % _text)
elif ("@EXAMPLE_ARANGOSH_OUTPUT" in _text or \
"@EXAMPLE_ARANGOSH_RUN" in _text):
elif ("@EXAMPLE_ARANGOSH_OUTPUT" in _text):
shouldIgnoreLine = True
_filename = re.search("{(.*)}", _text).group(1)
dirpath = os.path.abspath(os.path.join(os.path.dirname( __file__ ), os.pardir, "Examples", _filename + ".generated"))
@ -71,8 +70,7 @@ def fetch_comments(dirpath):
print "Could not find code for " + _filename
else:
fh.write("%s\n" % _text)
elif ("@END_EXAMPLE_ARANGOSH_OUTPUT" in _text or \
"@END_EXAMPLE_ARANGOSH_RUN" in _text):
elif ("@END_EXAMPLE_ARANGOSH_OUTPUT" in _text):
shouldIgnoreLine = False
fh.close()
@ -81,7 +79,7 @@ if __name__ == "__main__":
open("allComments.txt", "w").close()
path = ["arangod/cluster","arangod/RestHandler","arangod/V8Server",
"lib/Admin","lib/HttpServer",
"js/actions","js/client","js/apps","js/common","js/server"]
"js/actions","js/client","js/apps/databases","js/apps/system/cerberus","js/apps/system/gharial","js/common","js/server"]
for i in path:
dirpath = os.path.abspath(os.path.join(os.path.dirname( __file__ ), os.pardir,"ArangoDB/../../"+i))
fetch_comments(dirpath)

View File

@ -1427,8 +1427,28 @@ var _list = function() {
return _.pluck(gdb.toArray(), "_key");
};
////////////////////////////////////////////////////////////////////////////////
/// @brief create a list of edge definitions
/// @startDocuBlock JSF_general_graph_edge_definitions
///
/// The edge definitions for a graph is an array containing arbitrary many directed
/// and/or undirected relations as defined below.
/// The list of edge definitions of a graph can be managed by the graph module itself.
/// This function is the entry point for the management and will return the correct list.
///
/// @EXAMPLES
///
///
/// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphEdgeDefinitions}
/// var graph = require("org/arangodb/general-graph");
/// directed-relation = graph._directedRelationDefinition("lives_in", "user", "city");
/// undirected-relation = graph._directedRelationDefinition("knows", "user");
/// edgedefinitions = graph._edgeDefinitions(directed-relation, undirected-relation);
/// @END_EXAMPLE_ARANGOSH_OUTPUT
///
/// @endDocuBlock
////////////////////////////////////////////////////////////////////////////////
@ -1445,10 +1465,24 @@ var _edgeDefinitions = function () {
////////////////////////////////////////////////////////////////////////////////
/// @brief extend a list of edge definitions
/// @startDocuBlock JSF_general_graph_extend_edge_definitions
///
/// In order to add more edge definitions to the graph before creating
/// this function can be used to add more definitions to the initial list.
///
/// @EXAMPLES
///
/// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphEdgeDefinitionsExtend}
/// var graph = require("org/arangodb/general-graph");
/// directed-relation = graph._directedRelationDefinition("lives_in", "user", "city");
/// undirected-relation = graph._directedRelationDefinition("knows", "user");
/// edgedefinitions = graph._edgeDefinitions(directed-relation);
/// edgedefinitions = graph._extendEdgeDefinitions(undirected-relation);
/// @END_EXAMPLE_ARANGOSH_OUTPUT
///
/// @endDocuBlock
////////////////////////////////////////////////////////////////////////////////
var _extendEdgeDefinitions = function (edgeDefinition) {
var args = arguments, i = 0;
@ -1991,7 +2025,27 @@ var Graph = function(graphName, edgeDefinitions, vertexCollections, edgeCollecti
////////////////////////////////////////////////////////////////////////////////
/// @brief load a graph.
/// @startDocuBlock JSF_general_graph_graph
/// `general-graph._graph(graph-name)`
/// *Load a graph*
///
/// A graph can be loaded by its name.
///
/// * *graph-name*: string - unique identifier of the graph
///
/// @EXAMPLES
///
/// Load a graph:
///
/// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphVertexCollectionSave}
/// ~ var examples = require("org/arangodb/graph-examples/example-graph.js");
/// ~ var g1 = examples.loadGraph("social");
/// var graph = require("org/arangodb/general-graph");
/// g = graph._graph("social");
/// @END_EXAMPLE_ARANGOSH_OUTPUT
///
/// @endDocuBlock
///
////////////////////////////////////////////////////////////////////////////////
var _graph = function(graphName) {
@ -2070,7 +2124,31 @@ var checkIfMayBeDropped = function(colName, graphName, graphs) {
};
////////////////////////////////////////////////////////////////////////////////
/// @brief drop a graph.
/// @startDocuBlock JSF_general_graph_drop
/// `general-graph._drop(graph-name, drop-collections)`
/// *Remove a graph*
///
/// A graph can be dropped by its name.
/// This will automatically drop al collections contained in the graph as
/// long as they are not used within other graphs.
/// To prohibit the drop of collections, the optional parameter *drop-collections* can be set to *false*.
///
/// * *graph-name*: string - unique identifier of the graph
/// * *drop-collections*: boolean (optional) - Define if collections should be dropped (default: true)
///
/// @EXAMPLES
///
/// Drop a graph:
///
/// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphVertexCollectionSave}
/// ~ var examples = require("org/arangodb/graph-examples/example-graph.js");
/// ~ var g1 = examples.loadGraph("social");
/// var graph = require("org/arangodb/general-graph");
/// graph._drop("social");
/// @END_EXAMPLE_ARANGOSH_OUTPUT
///
/// @endDocuBlock
///
////////////////////////////////////////////////////////////////////////////////
var _drop = function(graphId, dropCollections) {