static string JS_graph = "////////////////////////////////////////////////////////////////////////////////\n" "/// @brief JavaScript actions functions\n" "///\n" "/// @file\n" "///\n" "/// DISCLAIMER\n" "///\n" "/// Copyright by triAGENS GmbH - All rights reserved.\n" "///\n" "/// The Programs (which include both the software and documentation)\n" "/// contain proprietary information of triAGENS GmbH; they are\n" "/// provided under a license agreement containing restrictions on use and\n" "/// disclosure and are also protected by copyright, patent and other\n" "/// intellectual and industrial property laws. Reverse engineering,\n" "/// disassembly or decompilation of the Programs, except to the extent\n" "/// required to obtain interoperability with other independently created\n" "/// software or as specified by law, is prohibited.\n" "///\n" "/// The Programs are not intended for use in any nuclear, aviation, mass\n" "/// transit, medical, or other inherently dangerous applications. It shall\n" "/// be the licensee's responsibility to take all appropriate fail-safe,\n" "/// backup, redundancy, and other measures to ensure the safe use of such\n" "/// applications if the Programs are used for such purposes, and triAGENS\n" "/// GmbH disclaims liability for any damages caused by such use of\n" "/// the Programs.\n" "///\n" "/// This software is the confidential and proprietary information of\n" "/// triAGENS GmbH. You shall not disclose such confidential and\n" "/// proprietary information and shall use it only in accordance with the\n" "/// terms of the license agreement you entered into with triAGENS GmbH.\n" "///\n" "/// Copyright holder is triAGENS GmbH, Cologne, Germany\n" "///\n" "/// @author Dr. Frank Celler\n" "/// @author Copyright 2011, triAGENS GmbH, Cologne, Germany\n" "////////////////////////////////////////////////////////////////////////////////\n" "\n" "var internal = require(\"internal\");\n" "\n" "////////////////////////////////////////////////////////////////////////////////\n" "/// @page Graphs First Steps with Graphs\n" "///\n" "/// Graphs consists of vertices and edges. The vertex collection contains the\n" "/// documents forming the vertices. The edge collection contains the documents\n" "/// forming the edges. Together both collections form a graph. Assume that\n" "/// the vertex collection is called @LIT{vertices} and the edges collection\n" "/// @LIT{edges}, then you can build a graph using the @FN{Graph} constructor.\n" "///\n" "/// @verbinclude graph25\n" "///\n" "/// It is possible to use different edges with the same vertices. For\n" "/// instance, to build a new graph with a different edge collection use\n" "///\n" "/// @verbinclude graph26\n" "////////////////////////////////////////////////////////////////////////////////\n" "\n" "////////////////////////////////////////////////////////////////////////////////\n" "/// @page GraphFuncIndexTOC\n" "///\n" "///
    \n" "///
  1. Graph
  2. \n" "///
      \n" "///
    1. @ref GraphFuncIndexGraphConstructor \"Graph constructor\"
    2. \n" "///
    3. @ref GraphFuncIndexGraphAddEdge \"Graph.addEdge\"
    4. \n" "///
    5. @ref GraphFuncIndexGraphAddVertex \"Graph.addVertex\"
    6. \n" "///
    7. @ref GraphFuncIndexGraphGetVertex \"Graph.getVertex\"
    8. \n" "///
    \n" "///
  3. Vertex
  4. \n" "///
      \n" "///
    1. @ref GraphFuncIndexVertexEdges \"Vertex.edges\"
    2. \n" "///
    3. @ref GraphFuncIndexVertexAddInEdge \"Vertex.addInEdge\"
    4. \n" "///
    5. @ref GraphFuncIndexVertexAddOutEdge \"Vertex.addOutEdge\"
    6. \n" "///
    7. @ref GraphFuncIndexVertexGetId \"Vertex.getId\"
    8. \n" "///
    9. @ref GraphFuncIndexVertexGetInEdges \"Vertex.getInEdges\"
    10. \n" "///
    11. @ref GraphFuncIndexVertexGetOutEdges \"Vertex.getOutEdges\"
    12. \n" "///
    13. @ref GraphFuncIndexVertexGetProperty \"Vertex.getProperty\"
    14. \n" "///
    15. @ref GraphFuncIndexVertexGetPropertyKeys \"Vertex.getPropertyKeys\"
    16. \n" "///
    17. @ref GraphFuncIndexVertexProperties \"Vertex.properties\"
    18. \n" "///
    19. @ref GraphFuncIndexVertexSetProperty \"Vertex.setProperty\"
    20. \n" "///
    \n" "///
  5. Edge
  6. \n" "///
      \n" "///
    1. @ref GraphFuncIndexEdgeGetId \"Edge.getId\"
    2. \n" "///
    3. @ref GraphFuncIndexEdgeGetInVertex \"Edge.getInVertex\"
    4. \n" "///
    5. @ref GraphFuncIndexEdgeGetLabel \"Edge.getLabel\"
    6. \n" "///
    7. @ref GraphFuncIndexEdgeGetOutVertex \"Edge.getOutVertex\"
    8. \n" "///
    9. @ref GraphFuncIndexEdgeGetProperty \"Edge.getProperty\"
    10. \n" "///
    11. @ref GraphFuncIndexEdgeGetPropertyKeys \"Edge.getPropertyKeys\"
    12. \n" "///
    13. @ref GraphFuncIndexEdgeProperties \"Edge.properties\"
    14. \n" "///
    15. @ref GraphFuncIndexEdgeSetProperty \"Edge.setProperty\"
    16. \n" "///
    \n" "/// \n" "///
\n" "////////////////////////////////////////////////////////////////////////////////\n" "\n" "////////////////////////////////////////////////////////////////////////////////\n" "/// @page GraphFuncIndex Index of Graph Functions\n" "///\n" "/// @copydoc GraphFuncIndexTOC\n" "///\n" "/// @section Graph\n" "///\n" "/// @anchor GraphFuncIndexGraphConstructor\n" "/// @copydetails JSF_Graph\n" "///\n" "/// @anchor GraphFuncIndexGraphAddEdge\n" "/// @copydetails JSF_Graph_prototype_addEdge\n" "///\n" "/// @anchor GraphFuncIndexGraphAddVertex\n" "/// @copydetails JSF_Graph_prototype_addVertex\n" "///\n" "/// @anchor GraphFuncIndexGraphGetVertex\n" "/// @copydetails JSF_Graph_prototype_getVertex\n" "///\n" "/// @section Vertex\n" "///\n" "/// @anchor GraphFuncIndexVertexEdges\n" "/// @copydetails JSF_Vertex_prototype_edges\n" "///\n" "/// @anchor GraphFuncIndexVertexAddInEdge\n" "/// @copydetails JSF_Vertex_prototype_addInEdge\n" "///\n" "/// @anchor GraphFuncIndexVertexAddOutEdge\n" "/// @copydetails JSF_Vertex_prototype_addOutEdge\n" "///\n" "/// @anchor GraphFuncIndexVertexGetId\n" "/// @copydetails JSF_Vertex_prototype_getId\n" "///\n" "/// @anchor GraphFuncIndexVertexGetInEdges\n" "/// @copydetails JSF_Vertex_prototype_getInEdges\n" "///\n" "/// @anchor GraphFuncIndexVertexGetOutEdges\n" "/// @copydetails JSF_Vertex_prototype_getOutEdges\n" "///\n" "/// @anchor GraphFuncIndexVertexGetProperty\n" "/// @copydetails JSF_Vertex_prototype_getProperty\n" "///\n" "/// @anchor GraphFuncIndexVertexGetPropertyKeys\n" "/// @copydetails JSF_Vertex_prototype_getPropertyKeys\n" "///\n" "/// @anchor GraphFuncIndexVertexProperties\n" "/// @copydetails JSF_Vertex_prototype_properties\n" "///\n" "/// @anchor GraphFuncIndexVertexSetProperty\n" "/// @copydetails JSF_Vertex_prototype_setProperty\n" "///\n" "/// @section Edge\n" "///\n" "/// @anchor GraphFuncIndexEdgeGetId\n" "/// @copydetails JSF_Edge_prototype_getId\n" "///\n" "/// @anchor GraphFuncIndexEdgeGetInVertex\n" "/// @copydetails JSF_Edge_prototype_getInVertex\n" "///\n" "/// @anchor GraphFuncIndexEdgeGetLabel\n" "/// @copydetails JSF_Edge_prototype_getLabel\n" "///\n" "/// @anchor GraphFuncIndexEdgeGetOutVertex\n" "/// @copydetails JSF_Edge_prototype_getOutVertex\n" "///\n" "/// @anchor GraphFuncIndexEdgeGetProperty\n" "/// @copydetails JSF_Edge_prototype_getProperty\n" "///\n" "/// @anchor GraphFuncIndexEdgeGetPropertyKeys\n" "/// @copydetails JSF_Edge_prototype_getPropertyKeys\n" "///\n" "/// @anchor GraphFuncIndexEdgeProperties\n" "/// @copydetails JSF_Edge_prototype_properties\n" "///\n" "/// @anchor GraphFuncIndexEdgeSetProperty\n" "/// @copydetails JSF_Edge_prototype_setProperty\n" "///\n" "////////////////////////////////////////////////////////////////////////////////\n" "\n" "// -----------------------------------------------------------------------------\n" "// --SECTION-- EDGE\n" "// -----------------------------------------------------------------------------\n" "\n" "// -----------------------------------------------------------------------------\n" "// --SECTION-- constructors and destructors\n" "// -----------------------------------------------------------------------------\n" "\n" "////////////////////////////////////////////////////////////////////////////////\n" "/// @addtogroup V8Json\n" "/// @{\n" "////////////////////////////////////////////////////////////////////////////////\n" "\n" "////////////////////////////////////////////////////////////////////////////////\n" "/// @brief constructs a new edge object\n" "////////////////////////////////////////////////////////////////////////////////\n" "\n" "function Edge (graph, id) {\n" " this._graph = graph;\n" " this._id = id;\n" "}\n" "\n" "////////////////////////////////////////////////////////////////////////////////\n" "/// @}\n" "////////////////////////////////////////////////////////////////////////////////\n" "\n" "// -----------------------------------------------------------------------------\n" "// --SECTION-- public functions\n" "// -----------------------------------------------------------------------------\n" "\n" "////////////////////////////////////////////////////////////////////////////////\n" "/// @addtogroup AvocadoGraph\n" "/// @{\n" "////////////////////////////////////////////////////////////////////////////////\n" "\n" "////////////////////////////////////////////////////////////////////////////////\n" "/// @brief returns the identifier of an edge\n" "///\n" "/// @FUN{@FA{edge}.getId()}\n" "///\n" "/// Returns the identifier of the @FA{edge}.\n" "///\n" "/// @verbinclude graph13\n" "////////////////////////////////////////////////////////////////////////////////\n" "\n" "Edge.prototype.getId = function (name) {\n" " return this._id;\n" "}\n" "\n" "////////////////////////////////////////////////////////////////////////////////\n" "/// @brief returns the to vertex\n" "///\n" "/// @FUN{@FA{edge}.getInVertex()}\n" "///\n" "/// Returns the vertex at the head of the @FA{edge}.\n" "///\n" "/// @verbinclude graph21\n" "////////////////////////////////////////////////////////////////////////////////\n" "\n" "Edge.prototype.getInVertex = function () {\n" " return this.graph.constructVertex(this._to);\n" "}\n" "\n" "////////////////////////////////////////////////////////////////////////////////\n" "/// @brief label of an edge\n" "///\n" "/// @FUN{@FA{edge}.getLabel()}\n" "///\n" "/// Returns the label of the @FA{edge}.\n" "///\n" "/// @verbinclude graph20\n" "////////////////////////////////////////////////////////////////////////////////\n" "\n" "Edge.prototype.getLabel = function () {\n" " if (! this.hasOwnProperty(\"_label\")) {\n" " this.properties();\n" " }\n" "\n" " return this._label;\n" "}\n" "\n" "////////////////////////////////////////////////////////////////////////////////\n" "/// @brief returns the from vertex\n" "///\n" "/// @FUN{@FA{edge}.getOutVertex()}\n" "///\n" "/// Returns the vertex at the tail of the @FA{edge}.\n" "///\n" "/// @verbinclude graph22\n" "////////////////////////////////////////////////////////////////////////////////\n" "\n" "Edge.prototype.getOutVertex = function () {\n" " return this._graph.constructVertex(this._from);\n" "}\n" "\n" "////////////////////////////////////////////////////////////////////////////////\n" "/// @brief returns a property of an edge\n" "///\n" "/// @FUN{@FA{edge}.getProperty(@FA{name})}\n" "///\n" "/// Returns the property @FA{name} an @FA{edge}.\n" "///\n" "/// @verbinclude graph12\n" "////////////////////////////////////////////////////////////////////////////////\n" "\n" "Edge.prototype.getProperty = function (name) {\n" " var props;\n" "\n" " props = this.properties();\n" "\n" " return props[name]\n" "}\n" "\n" "////////////////////////////////////////////////////////////////////////////////\n" "/// @brief gets all property names of an edge\n" "///\n" "/// @FUN{@FA{vertex}.getPropertyKeys()}\n" "///\n" "/// Returns all propety names a @FA{vertex}.\n" "///\n" "/// @verbinclude graph7\n" "////////////////////////////////////////////////////////////////////////////////\n" "\n" "Edge.prototype.getPropertyKeys = function () {\n" " var keys;\n" " var key;\n" " var props;\n" "\n" " props = this.properties();\n" " keys = [];\n" "\n" " for (key in props) {\n" " if (props.hasOwnProperty(key)) {\n" " keys.push(key);\n" " }\n" " }\n" "\n" " return keys;\n" "}\n" "\n" "////////////////////////////////////////////////////////////////////////////////\n" "/// @brief changes a property of an edge\n" "///\n" "/// @FUN{@FA{edge}.setProperty(@FA{name}, @FA{value})}\n" "///\n" "/// Changes or sets the property @FA{name} an @FA{edges} to @FA{value}.\n" "///\n" "/// @verbinclude graph14\n" "////////////////////////////////////////////////////////////////////////////////\n" "\n" "Edge.prototype.setProperty = function (name, value) {\n" " var query;\n" " var props;\n" "\n" " delete this._properties;\n" "\n" " query = this._graph._edges.document(this._id); // TODO use \"update\"\n" "\n" " if (query.hasNext()) {\n" " props = query.next();\n" "\n" " props[name] = value;\n" "\n" " this._graph._edges.replace(this._id, props);\n" "\n" " return value;\n" " }\n" " else {\n" " return undefined;\n" " }\n" "}\n" "\n" "////////////////////////////////////////////////////////////////////////////////\n" "/// @brief returns all properties of an edge\n" "///\n" "/// @FUN{@FA{edge}.properties()}\n" "///\n" "/// Returns all properties and their values of an @FA{edge}\n" "///\n" "/// @verbinclude graph11\n" "////////////////////////////////////////////////////////////////////////////////\n" "\n" "Edge.prototype.properties = function () {\n" " var query;\n" " var prop;\n" "\n" " if (! this.hasOwnProperty(\"_properties\")) {\n" " query = this._graph._edges.document(this._id);\n" "\n" " if (query.hasNext()) {\n" " this._properties = query.next();\n" " this._label = this._properties._label;\n" " this._from = this._properties._from;\n" " this._to = this._properties._to;\n" "\n" " delete this._properties._id;\n" " delete this._properties._label;\n" " delete this._properties._from;\n" " delete this._properties._to;\n" " }\n" " else {\n" " return undefined;\n" " }\n" " }\n" "\n" " return this._properties;\n" "}\n" "\n" "////////////////////////////////////////////////////////////////////////////////\n" "/// @}\n" "////////////////////////////////////////////////////////////////////////////////\n" "\n" "// -----------------------------------------------------------------------------\n" "// --SECTION-- private methods\n" "// -----------------------------------------------------------------------------\n" "\n" "////////////////////////////////////////////////////////////////////////////////\n" "/// @addtogroup AvocadoGraph\n" "/// @{\n" "////////////////////////////////////////////////////////////////////////////////\n" "\n" "////////////////////////////////////////////////////////////////////////////////\n" "/// @brief edge printing\n" "////////////////////////////////////////////////////////////////////////////////\n" "\n" "Edge.prototype.PRINT = function () {\n" " internal.output(\"Edge(, \\\"\", this._id, \"\\\")\");\n" "}\n" "\n" "////////////////////////////////////////////////////////////////////////////////\n" "/// @}\n" "////////////////////////////////////////////////////////////////////////////////\n" "\n" "// -----------------------------------------------------------------------------\n" "// --SECTION-- VERTEX\n" "// -----------------------------------------------------------------------------\n" "\n" "// -----------------------------------------------------------------------------\n" "// --SECTION-- constructors and destructors\n" "// -----------------------------------------------------------------------------\n" "\n" "////////////////////////////////////////////////////////////////////////////////\n" "/// @addtogroup AvocadoGraph\n" "/// @{\n" "////////////////////////////////////////////////////////////////////////////////\n" "\n" "////////////////////////////////////////////////////////////////////////////////\n" "/// @brief constructs a new vertex object\n" "////////////////////////////////////////////////////////////////////////////////\n" "\n" "function Vertex (graph, id) {\n" " this._graph = graph;\n" " this._id = id;\n" "}\n" "\n" "////////////////////////////////////////////////////////////////////////////////\n" "/// @}\n" "////////////////////////////////////////////////////////////////////////////////\n" "\n" "// -----------------------------------------------------------------------------\n" "// --SECTION-- public functions\n" "// -----------------------------------------------------------------------------\n" "\n" "////////////////////////////////////////////////////////////////////////////////\n" "/// @addtogroup AvocadoGraph\n" "/// @{\n" "////////////////////////////////////////////////////////////////////////////////\n" "\n" "////////////////////////////////////////////////////////////////////////////////\n" "/// @brief adds an inbound edge\n" "///\n" "/// @FUN{@FA{vertex}.addInEdge(@FA{peer}, @FA{label})}\n" "///\n" "/// Creates a new edge from @FA{peer} to @FA{vertex} with given label and\n" "/// returns the edge object.\n" "///\n" "/// @verbinclude graph23\n" "///\n" "/// @FUN{@FA{vertex}.addInEdge(@FA{peer}, @FA{label}, @FA{data})}\n" "///\n" "/// Creates a new edge from @FA{peer} to @FA{vertex} with given label and\n" "/// properties defined in @FA{data}. Returns the edge object.\n" "///\n" "/// @verbinclude graph24\n" "////////////////////////////////////////////////////////////////////////////////\n" "\n" "Vertex.prototype.addInEdge = function (out, label, data) {\n" " return this._graph.addEdge(out, this, label, data);\n" "}\n" "\n" "////////////////////////////////////////////////////////////////////////////////\n" "/// @brief adds an outbound edge\n" "///\n" "/// @FUN{@FA{vertex}.addOutEdge(@FA{peer}, @FA{label})}\n" "///\n" "/// Creates a new edge from @FA{vertex} to @FA{peer} with given @FA{label} and\n" "/// returns the edge object.\n" "///\n" "/// @verbinclude graph23\n" "///\n" "/// @FUN{@FA{vertex}.addOutEdge(@FA{peer}, @FA{label}, @FA{data})}\n" "///\n" "/// Creates a new edge from @FA{vertex} to @FA{peer} with given @FA{label} and\n" "/// properties defined in @FA{data}. Returns the edge object.\n" "///\n" "/// @verbinclude graph24\n" "////////////////////////////////////////////////////////////////////////////////\n" "\n" "Vertex.prototype.addOutEdge = function (ine, label, data) {\n" " return this._graph.addEdge(this, ine, label, data);\n" "}\n" "\n" "////////////////////////////////////////////////////////////////////////////////\n" "/// @brief inbound and outbound edges\n" "///\n" "/// @FUN{@FA{vertex}.edges()}\n" "///\n" "/// Returns a list of in- or outbound edges of the @FA{vertex}.\n" "///\n" "/// @verbinclude graph15\n" "////////////////////////////////////////////////////////////////////////////////\n" "\n" "Vertex.prototype.edges = function () {\n" " var query;\n" " var result;\n" " var graph;\n" "\n" " if (! this.hasOwnProperty(\"_edges\")) {\n" " graph = this._graph;\n" " query = graph._vertices.document(this._id).edges(graph._edges);\n" " result = [];\n" "\n" " while (query.hasNext()) {\n" " result.push(graph.constructEdge(query.nextRef()));\n" " }\n" "\n" " this._edges = result;\n" " }\n" "\n" " return this._edges;\n" "}\n" "\n" "////////////////////////////////////////////////////////////////////////////////\n" "/// @brief returns the identifier of a vertex\n" "///\n" "/// @FUN{@FA{vertex}.getId()}\n" "///\n" "/// Returns the identifier of the @FA{vertex}.\n" "///\n" "/// @verbinclude graph8\n" "////////////////////////////////////////////////////////////////////////////////\n" "\n" "Vertex.prototype.getId = function (name) {\n" " return this._id;\n" "}\n" "\n" "////////////////////////////////////////////////////////////////////////////////\n" "/// @brief inbound edges with given label\n" "///\n" "/// @FUN{@FA{vertex}.getInEdges(@FA{label}, ...)}\n" "///\n" "/// Returns a list of inbound edges of the @FA{vertex} with given label(s).\n" "///\n" "/// @verbinclude graph18\n" "////////////////////////////////////////////////////////////////////////////////\n" "\n" "Vertex.prototype.getInEdges = function () {\n" " var edges;\n" " var labels;\n" " var result;\n" " var edge;\n" "\n" " if (arguments.length == 0) {\n" " return this.inbound();\n" " }\n" " else {\n" " labels = {};\n" "\n" " for (var i = 0; i < arguments.length; ++i) {\n" " labels[arguments[i]] = true;\n" " }\n" "\n" " edges = this.inbound();\n" " result = [];\n" "\n" " for (var i = 0; i < edges.length; ++i) {\n" " if (edges[i].getLabel() in labels) {\n" " result.push(edges[i]);\n" " }\n" " }\n" "\n" " return result;\n" " }\n" "}\n" "\n" "////////////////////////////////////////////////////////////////////////////////\n" "/// @brief outbound edges with given label\n" "///\n" "/// @FUN{@FA{vertex}.getOutEdges(@FA{label}, ...)}\n" "///\n" "/// Returns a list of outbound edges of the @FA{vertex} with given label(s).\n" "///\n" "/// @verbinclude graph19\n" "////////////////////////////////////////////////////////////////////////////////\n" "\n" "Vertex.prototype.getOutEdges = function () {\n" " var edges;\n" " var labels;\n" " var result;\n" " var edge;\n" "\n" " if (arguments.length == 0) {\n" " return this.outbound();\n" " }\n" " else {\n" " labels = {};\n" "\n" " for (var i = 0; i < arguments.length; ++i) {\n" " labels[arguments[i]] = true;\n" " }\n" "\n" " edges = this.outbound();\n" " result = [];\n" "\n" " for (var i = 0; i < edges.length; ++i) {\n" " if (edges[i].getLabel() in labels) {\n" " result.push(edges[i]);\n" " }\n" " }\n" "\n" " return result;\n" " }\n" "}\n" "\n" "////////////////////////////////////////////////////////////////////////////////\n" "/// @brief returns a property of a vertex\n" "///\n" "/// @FUN{@FA{vertex}.getProperty(@FA{name})}\n" "///\n" "/// Returns the property @FA{name} a @FA{vertex}.\n" "///\n" "/// @verbinclude graph5\n" "////////////////////////////////////////////////////////////////////////////////\n" "\n" "Vertex.prototype.getProperty = function (name) {\n" " var props;\n" "\n" " props = this.properties();\n" "\n" " return props[name]\n" "}\n" "\n" "////////////////////////////////////////////////////////////////////////////////\n" "/// @brief gets all property names of a vertex\n" "///\n" "/// @FUN{@FA{vertex}.getPropertyKeys()}\n" "///\n" "/// Returns all propety names a @FA{vertex}.\n" "///\n" "/// @verbinclude graph7\n" "////////////////////////////////////////////////////////////////////////////////\n" "\n" "Vertex.prototype.getPropertyKeys = function () {\n" " var keys;\n" " var key;\n" " var props;\n" "\n" " props = this.properties();\n" " keys = [];\n" "\n" " for (key in props) {\n" " if (props.hasOwnProperty(key)) {\n" " keys.push(key);\n" " }\n" " }\n" "\n" " return keys;\n" "}\n" "\n" "////////////////////////////////////////////////////////////////////////////////\n" "/// @brief inbound edges\n" "///\n" "/// @FUN{@FA{vertex}.inbound()}\n" "///\n" "/// Returns a list of inbound edges of the @FA{vertex}.\n" "///\n" "/// @verbinclude graph16\n" "////////////////////////////////////////////////////////////////////////////////\n" "\n" "Vertex.prototype.inbound = function () {\n" " var query;\n" " var result;\n" " var graph;\n" "\n" " if (! this.hasOwnProperty(\"_inbound\")) {\n" " graph = this._graph;\n" " query = graph._vertices.document(this._id).inEdges(graph._edges);\n" " result = [];\n" "\n" " while (query.hasNext()) {\n" " result.push(graph.constructEdge(query.nextRef()));\n" " }\n" "\n" " this._inbound = result;\n" " }\n" "\n" " return this._inbound;\n" "}\n" "\n" "////////////////////////////////////////////////////////////////////////////////\n" "/// @brief outbound edges\n" "///\n" "/// @FUN{@FA{vertex}.outbound()}\n" "///\n" "/// Returns a list of outbound edges of the @FA{vertex}.\n" "///\n" "/// @verbinclude graph17\n" "////////////////////////////////////////////////////////////////////////////////\n" "\n" "Vertex.prototype.outbound = function () {\n" " var query;\n" " var result;\n" " var graph;\n" "\n" " if (! this.hasOwnProperty(\"_outbound\")) {\n" " graph = this._graph;\n" " query = graph._vertices.document(this._id).outEdges(graph._edges);\n" " result = [];\n" "\n" " while (query.hasNext()) {\n" " result.push(graph.constructEdge(query.nextRef()));\n" " }\n" "\n" " this._outbound = result;\n" " }\n" "\n" " return this._outbound;\n" "}\n" "\n" "////////////////////////////////////////////////////////////////////////////////\n" "/// @brief returns all properties of a vertex\n" "///\n" "/// @FUN{@FA{vertex}.properties()}\n" "///\n" "/// Returns all properties and their values of a @FA{vertex}\n" "///\n" "/// @verbinclude graph4\n" "////////////////////////////////////////////////////////////////////////////////\n" "\n" "Vertex.prototype.properties = function () {\n" " var query;\n" " var prop;\n" "\n" " if (! this.hasOwnProperty(\"_properties\")) {\n" " query = this._graph._vertices.document(this._id);\n" "\n" " if (query.hasNext()) {\n" " this._properties = query.next();\n" " delete this._properties._id;\n" " }\n" " else {\n" " return undefined;\n" " }\n" " }\n" "\n" " return this._properties;\n" "}\n" "\n" "////////////////////////////////////////////////////////////////////////////////\n" "/// @brief changes a property of a vertex\n" "///\n" "/// @FUN{@FA{vertex}.setProperty(@FA{name}, @FA{value})}\n" "///\n" "/// Changes or sets the property @FA{name} a @FA{vertex} to @FA{value}.\n" "///\n" "/// @verbinclude graph6\n" "////////////////////////////////////////////////////////////////////////////////\n" "\n" "Vertex.prototype.setProperty = function (name, value) {\n" " var query;\n" " var props;\n" "\n" " delete this._properties;\n" "\n" " query = this._graph._vertices.document(this._id); // TODO use \"update\"\n" "\n" " if (query.hasNext()) {\n" " props = query.next();\n" "\n" " props[name] = value;\n" "\n" " this._graph._vertices.replace(this._id, props);\n" "\n" " return value;\n" " }\n" " else {\n" " return undefined;\n" " }\n" "}\n" "\n" "////////////////////////////////////////////////////////////////////////////////\n" "/// @}\n" "////////////////////////////////////////////////////////////////////////////////\n" "\n" "// -----------------------------------------------------------------------------\n" "// --SECTION-- private methods\n" "// -----------------------------------------------------------------------------\n" "\n" "////////////////////////////////////////////////////////////////////////////////\n" "/// @addtogroup AvocadoGraph\n" "/// @{\n" "////////////////////////////////////////////////////////////////////////////////\n" "\n" "////////////////////////////////////////////////////////////////////////////////\n" "/// @brief vertex representation\n" "////////////////////////////////////////////////////////////////////////////////\n" "\n" "Vertex.prototype.PRINT = function () {\n" " internal.output(\"Vertex(, \\\"\", this._id, \"\\\")\");\n" "}\n" "\n" "////////////////////////////////////////////////////////////////////////////////\n" "/// @}\n" "////////////////////////////////////////////////////////////////////////////////\n" "\n" "// -----------------------------------------------------------------------------\n" "// --SECTION-- GRAPH\n" "// -----------------------------------------------------------------------------\n" "\n" "// -----------------------------------------------------------------------------\n" "// --SECTION-- constructors and destructors\n" "// -----------------------------------------------------------------------------\n" "\n" "////////////////////////////////////////////////////////////////////////////////\n" "/// @addtogroup AvocadoGraph\n" "/// @{\n" "////////////////////////////////////////////////////////////////////////////////\n" "\n" "////////////////////////////////////////////////////////////////////////////////\n" "/// @brief constructs a new graph object\n" "///\n" "/// @FUN{Graph(@FA{vertices}, @FA{edges})}\n" "///\n" "/// Constructs a new graph object using the collection @FA{vertices} for all\n" "/// vertices and the collection @FA{edges} for all edges.\n" "///\n" "/// @verbinclude graph1\n" "////////////////////////////////////////////////////////////////////////////////\n" "\n" "function Graph (vertices, edg) {\n" " if (typeof vertices === \"string\") {\n" " vertices = db[vertices];\n" " }\n" " else if (! vertices instanceof AvocadoCollection) {\n" " throw \" must be a document collection\";\n" " }\n" "\n" " if (typeof edg === \"string\") {\n" " edg = edges[edg];\n" " }\n" " else if (! edg instanceof AvocadoEdgesCollection) {\n" " throw \" must be an edges collection\";\n" " }\n" "\n" " this._vertices = vertices;\n" " this._verticesCache = {};\n" "\n" " this._edges = edg;\n" " this._edgesCache = {};\n" "}\n" "\n" "////////////////////////////////////////////////////////////////////////////////\n" "/// @}\n" "////////////////////////////////////////////////////////////////////////////////\n" "\n" "// -----------------------------------------------------------------------------\n" "// --SECTION-- public functions\n" "// -----------------------------------------------------------------------------\n" "\n" "////////////////////////////////////////////////////////////////////////////////\n" "/// @addtogroup AvocadoGraph\n" "/// @{\n" "////////////////////////////////////////////////////////////////////////////////\n" "\n" "////////////////////////////////////////////////////////////////////////////////\n" "/// @brief adds an edge to the graph\n" "///\n" "/// @FUN{@FA{graph}.addEdge(@FA{out}, @FA{in})}\n" "///\n" "/// Creates a new edge from @FA{out} to @FA{in} and returns the edge\n" "/// object.\n" "///\n" "/// @FUN{@FA{graph}.addEdge(@FA{out}, @FA{in}, @FA{label})}\n" "///\n" "/// Creates a new edge from @FA{out} to @FA{in} with @FA{label} and returns the\n" "/// edge object.\n" "///\n" "/// @verbinclude graph9\n" "///\n" "/// @FUN{@FA{graph}.addEdge(@FA{out}, @FA{in}, @FA{data})}\n" "///\n" "/// Creates a new edge and returns the edge object. The edge contains the\n" "/// properties defined in @FA{data}.\n" "///\n" "/// @FUN{@FA{graph}.addEdge(@FA{out}, @FA{in}, @FA{label}, @FA{data})}\n" "///\n" "/// Creates a new edge and returns the edge object. The edge has the\n" "/// label @FA{label} and contains the properties defined in @FA{data}.\n" "///\n" "/// @verbinclude graph10\n" "////////////////////////////////////////////////////////////////////////////////\n" "\n" "Graph.prototype.addEdge = function (out, ine, label, data) {\n" " var ref;\n" " var shallow;\n" " var key;\n" " var edge;\n" "\n" " if (typeof label === 'object') {\n" " data = label;\n" " label = undefined;\n" " }\n" "\n" " if (label === undefined) {\n" " label = null;\n" " }\n" "\n" " if (data === undefined) {\n" " ref = this._edges.save(out._id, ine._id, {\"_label\" : label});\n" " }\n" " else {\n" " shallow = {};\n" "\n" " for (key in data) {\n" " if (data.hasOwnProperty(key)) {\n" " shallow[key] = data[key];\n" " }\n" " }\n" "\n" " shallow[\"_label\"] = label;\n" "\n" " ref = this._edges.save(out._id, ine._id, shallow);\n" " }\n" "\n" " edge = this.constructEdge(ref);\n" "\n" " if (out.hasOwnProperty(\"_edges\")) {\n" " out._edges.push(edge);\n" " }\n" "\n" " if (out.hasOwnProperty(\"_outbound\")) {\n" " out._outbound.push(edge);\n" " }\n" "\n" " if (ine.hasOwnProperty(\"_edges\")) {\n" " ine._edges.push(edge);\n" " }\n" "\n" " if (ine.hasOwnProperty(\"_inbound\")) {\n" " ine._inbound.push(edge);\n" " }\n" "\n" " return edge;\n" "}\n" "\n" "////////////////////////////////////////////////////////////////////////////////\n" "/// @brief adds a vertex to the graph\n" "///\n" "/// @FUN{@FA{graph}.addVertex()}\n" "///\n" "/// Creates a new vertex and returns the vertex object.\n" "///\n" "/// @verbinclude graph2\n" "///\n" "/// @FUN{@FA{graph}.addVertex(@FA{data})}\n" "///\n" "/// Creates a new vertex and returns the vertex object. The vertex contains\n" "/// the properties defined in @FA{data}.\n" "///\n" "/// @verbinclude graph3\n" "////////////////////////////////////////////////////////////////////////////////\n" "\n" "Graph.prototype.addVertex = function (data) {\n" " var ref;\n" "\n" " if (data === undefined) {\n" " ref = this._vertices.save({});\n" " }\n" " else {\n" " ref = this._vertices.save(data);\n" " }\n" "\n" " return this.constructVertex(ref);\n" "}\n" "\n" "////////////////////////////////////////////////////////////////////////////////\n" "/// @brief returns a vertex given its id\n" "///\n" "/// @FUN{@FA{graph}.getVertex(@FA{id})}\n" "///\n" "/// Returns the vertex identified by @FA{id} or undefined.\n" "///\n" "/// @verbinclude graph2\n" "////////////////////////////////////////////////////////////////////////////////\n" "\n" "Graph.prototype.getVertex = function (id) {\n" " var ref;\n" "\n" " ref = this._vertices.document(id);\n" "\n" " if (ref.count() == 1) {\n" " return this.constructVertex(id);\n" " }\n" " else {\n" " return undefined;\n" " }\n" "}\n" "\n" "////////////////////////////////////////////////////////////////////////////////\n" "/// @}\n" "////////////////////////////////////////////////////////////////////////////////\n" "\n" "// -----------------------------------------------------------------------------\n" "// --SECTION-- private functions\n" "// -----------------------------------------------------------------------------\n" "\n" "////////////////////////////////////////////////////////////////////////////////\n" "/// @addtogroup AvocadoGraph\n" "/// @{\n" "////////////////////////////////////////////////////////////////////////////////\n" "\n" "////////////////////////////////////////////////////////////////////////////////\n" "/// @brief private function to construct a vertex\n" "////////////////////////////////////////////////////////////////////////////////\n" "\n" "Graph.prototype.constructVertex = function(id) {\n" " if (! (id in this._verticesCache)) {\n" " this._verticesCache[id] = new Vertex(this, id);\n" " }\n" "\n" " return this._verticesCache[id];\n" "}\n" "\n" "////////////////////////////////////////////////////////////////////////////////\n" "/// @brief private function to construct an edge\n" "////////////////////////////////////////////////////////////////////////////////\n" "\n" "Graph.prototype.constructEdge = function(id) {\n" " if (! (id in this._edgesCache)) {\n" " this._edgesCache[id] = new Edge(this, id);\n" " }\n" "\n" " return this._edgesCache[id];\n" "}\n" "\n" "////////////////////////////////////////////////////////////////////////////////\n" "/// @brief graph printing\n" "////////////////////////////////////////////////////////////////////////////////\n" "\n" "Graph.prototype.PRINT = function () {\n" " internal.output(\"Graph(\\\"\", this._vertices._name, \"\\\", \\\"\" + this._edges._name, \"\\\")\");\n" "}\n" "\n" "////////////////////////////////////////////////////////////////////////////////\n" "/// @}\n" "////////////////////////////////////////////////////////////////////////////////\n" "\n" "// Local Variables:\n" "// mode: outline-minor\n" "// outline-regexp: \"^\\\\(/// @brief\\\\|/// @addtogroup\\\\|// --SECTION--\\\\|/// @page\\\\|/// @}\\\\)\"\n" "// End:\n" ;