.. _nctx.undirected: Process undirected graphs: nctx.undirected ========================================== .. testsetup:: * import nctx.undirected from nctx.undirected import * .. toctree:: :maxdepth: 2 :caption: Contents: This submodule provides functionality for undirected graphs. The examples on this page all build on the same graph: >>> import nctx.undirected as nctx >>> g = nctx.Graph() >>> name_map = nctx.PropertyMapStr(g, 'name') >>> context_map = PropertyMapVecDouble(g, 'context') >>> nctx.read_graphml(g, 'bcde.ctx.undir.graphml', [name_map, context_map]) If you load this module, all operations refer to undirected graphs. Up to now, there is no possibility to convert a undirected graph into a directed one or vice versa. This will be added in future versions. .. todo:: Functionality to convert undirected to directed graphs. The Graph Class --------------- .. csv-table:: Summary :widths: 20, 50 ":py:func:`Graph `", "This class represents an undirected graph." ":py:func:`__hash__ `", "" ":py:func:`__init__ `", "" ":py:func:`add_edge `", "Add an edge that connects u and v." ":py:func:`add_vertex `", "Add a vertex to the graph." ":py:func:`children `", "Iterate over the children of a given vertex u." ":py:func:`edges `", "Iterate over the edges of the graph." ":py:func:`in_edges `", "Iterate over the incoming edges of a vertex." ":py:func:`numEdges `", "Retrieve the number of edges in the graph." ":py:func:`numVertices `", "Retrieve the number of vertices in the graph." ":py:func:`out_edges `", "Iterate over the outgoing edges of a vertex." ":py:func:`parents `", "Iterate over the parents of a given vertex u." ":py:func:`source `", "Retrieve the source vertex of an edge." ":py:func:`target `", "Retrieve the target vertex of an edge." ":py:func:`vertices `", "Iterate over the vertices of the graph." .. py:class:: nctx.undirected.Graph This class represents an undirected graph. :Example: >>> import nctx.undirected as nctx >>> graph = nctx.Graph() .. py:method:: nctx.undirected.Graph.__hash__( ) -> int Not commented yet .. py:method:: nctx.undirected.Graph.__init__( (object)arg1) -> None Not commented yet .. py:method:: nctx.undirected.Graph.add_edge( (int)u, (int)v) -> bool : Add an edge that connects u and v. :return: Status if adding the edge was successful. :rtype: bool :Example: >>> from collections import defaultdict >>> vertices = defaultdict(lambda: graph.add_vertex()) >>> for i in range(10): ... _ = vertices[i] >>> graph.add_edge(vertices[0], vertices[1]) True .. py:method:: nctx.undirected.Graph.add_vertex( ) -> int : Add a vertex to the graph. :return: The ID of the added vertex. :rtype: int :Example: >>> from collections import defaultdict >>> name_map = nctx.PropertyMapStr(graph, 'name') >>> vertices = defaultdict(lambda: graph.add_vertex()) >>> for i in range(10): ... v = vertices[i] ... name_map.set_elem(v, f"vertex {i}") .. py:method:: nctx.undirected.Graph.children( (int)u) -> a_iter_ids : Iterate over the children of a given vertex u. Since there is no difference between children and parents in an undirected graph, :py:func:`children ` yields the same list of vertices as :py:func:`parents ` :param u: ID of the vertex whose children should be iterated. :type u: int :return: A vertex iterator :rtype: v_iter_ids :Example: >>> some_vertex = 0 >>> for c in g.children(some_vertex): ... pass .. py:method:: nctx.undirected.Graph.edges( ) -> e_iter_ids : Iterate over the edges of the graph. Use :py:func:`source ` to access the source vertex of an edge and :py:func:`target ` to access its target. Note that incoming and outgoing edges are not distinguished in an undirected graph, therefore :py:func:`in_edges `, :py:func:`out_edges `, and this function all yield the same results. :return: The edge iterator :rtype: e_iter_ids :Example: >>> for e in g.edges(): ... source_vertex = g.source(e) ... target_vertex = g.target(e) .. py:method:: nctx.undirected.Graph.in_edges( (int)arg2) -> e_iter_ids_in : Iterate over the incoming edges of a vertex. Use :py:func:`source ` to access the source vertex of an edge. :param v: ID of the vertex whose in-edges should be iterated. :type v: int :return: The in-edge iterator :rtype: e_iter_ids_in :Example: >>> v=4 >>> for e in g.in_edges(v): ... source_vertex = g.source(e) .. py:method:: nctx.undirected.Graph.numEdges( ) -> int : Retrieve the number of edges in the graph. :return: The number of edges :rtype: int .. py:method:: nctx.undirected.Graph.numVertices( ) -> int : Retrieve the number of vertices in the graph. :return: The number of vertices :rtype: int .. py:method:: nctx.undirected.Graph.out_edges( (int)arg2) -> e_iter_ids_out : Iterate over the outgoing edges of a vertex. Use :py:func:`target ` to access the target vertex of an edge. :param v: ID of the vertex whose out-edges should be iterated. :type v: int :return: The out-edge iterator :rtype: e_iter_ids_out :Example: >>> v=4 >>> for e in g.in_edges(v): ... target_vertex = g.target(e) .. py:method:: nctx.undirected.Graph.parents( (int)u) -> a_iter_ids_rev : Iterate over the parents of a given vertex u. Since there is no difference between children and parents in an undirected graph, :py:func:`parents ` yields the same list of vertices as :py:func:`children ` :param u: ID of the vertex whose parents should be iterated. :type u: int :return: A vertex iterator :rtype: v_iter_ids :Example: >>> some_vertex = 0 >>> for p in g.parents(some_vertex): ... pass .. py:method:: nctx.undirected.Graph.source( (Edge)e) -> int : Retrieve the source vertex of an edge. See :py:func:`edges ` for an example. :param e: An edge. :type e: Edge :return: The ID of the source vertex :rtype: int .. py:method:: nctx.undirected.Graph.target( (Edge)e) -> int : Retrieve the target vertex of an edge. See :py:func:`edges ` for an example. :param e: An edge. :type e: Edge :return: The ID of the target vertex :rtype: int .. py:method:: nctx.undirected.Graph.vertices( ) -> v_iter_ids : Iterate over the vertices of the graph. :return: A vertex iterator :rtype: v_iter_ids :Example: >>> for v in g.vertices(): ... pass AlgPaths: Shortest-path discovery --------------------------------- .. csv-table:: Summary :widths: 20, 50 ":py:func:`AlgPaths `", "" ":py:func:`dijkstra `", "Conventional single-source shortest paths discovery using Dijkstra's algorithm." ":py:func:`dijkstra_apsp_ctx `", "Obtain all-pairs-shortest-paths using Dijkstra's algorithm taking into account contextual constraints." ":py:func:`dijkstra_ctx `", "Obtain shortest paths with dynamic contextual constraints." ":py:func:`find_path `", "Conventional shortest path discovery using Dijkstra's algorithm." ":py:func:`find_path_ctx `", "Obtain a shortest paths from a start vertex to a target vertex using Dijkstra's algorithm taking into account contextual constraints." .. py:class:: nctx.undirected.AlgPaths .. py:method:: nctx.undirected.AlgPaths.dijkstra( (Graph)g, (int)start, (PropertyMapULong)distances) -> None : :noindex: .. py:method:: nctx.undirected.AlgPaths.dijkstra( (Graph)g, (int)start) -> PropertyMapULong : Conventional single-source shortest paths discovery using Dijkstra's algorithm. :param g: The Graph object :type g: Graph :param start: Source vertex :type start: int :param distances: PropertyMap in which distances will be written. :type distances: PropertyMapULong :return: PropertyMap with distances. :rtype: PropertyMapULong .. py:method:: nctx.undirected.AlgPaths.dijkstra_apsp_ctx( (Graph)g, (object)decision_fct, (PropertyMapVecULong)distances) -> None : :noindex: .. py:method:: nctx.undirected.AlgPaths.dijkstra_apsp_ctx( (Graph)g, (object)decision_fct) -> PropertyMapVecULong : Obtain all-pairs-shortest-paths using Dijkstra's algorithm taking into account contextual constraints. This is basically a wrapper around :py:func:`dijkstra_ctx `. Please see the mentioned function for more information regarding the contextual constraints. :param g: The Graph object :type g: Graph :param decision_fct: The decision function enforcing contextual constraints. The signature of the function is ``(vertex index, vertex index, vertex index) -> Bool`` :type decision_fct: function :param distances: matrix in which distances will be written :type distances: PropertyMapVecULong :return: matrix of distances named apsp_constraint :rtype: PropertyMapVecULong :Example: >>> distmap = PropertyMapVecULong(g, 'distances_ctx') >>> AlgPaths.dijkstra_apsp_ctx(g,lambda _start,_current,_next: (True), distmap) :Example: >>> distmap = AlgPaths.dijkstra_apsp_ctx(g,lambda _start,_current,_next: (True)) .. py:method:: nctx.undirected.AlgPaths.dijkstra_ctx( (Graph)g, (int)s, (object)decision_fct, (PropertyMapULong)distances) -> None : :noindex: .. py:method:: nctx.undirected.AlgPaths.dijkstra_ctx( (Graph)g, (int)s, (object)decision_fct) -> PropertyMapULong : Obtain shortest paths with dynamic contextual constraints. Single-source shortest paths using Dijkstra's algorithm taking into account contextual constraints. Enforcement of constraints is the task of the given user-defined function. The function enforcing contextual constraints is evaluated at each node during shortest path discovery. The function needs to evaluate to ``true`` or ``false`` allowing an edge to be visited or not. As parameters, the function needs to accept the starting node of path traversal, the current node, and the descending node in question. If the function returns False, the descending node is not being visited. Passing the start vertex is unnecessary here. However, the signature is the same as for the other functions for usability reasons. The three nodes are passed as indices allowing for access of (external) attribute and other associated information. Note that the decision function is evaluated more than once during path traversal. That means, there should not happen any resource-intense computation inside this function. Also, it does not allow to keep track of the status of calculation, e.g. by calculating the visited edges or something similar. If the decision function simply returns True all the time, the set of shortest paths is the unaltered set of shortest paths expected by the classical Dijkstra-implementation. :param distances: map in which distances will be written :type distances: PropertyMapULong :return: map containing distances named dijkstra_constraint :rtype: PropertyMapULong :Example: >>> start = 3 >>> distmap = PropertyMapULong(g, 'distances_ctx') >>> AlgPaths.dijkstra_ctx(g, start, lambda _start,_current,_next: (True), distmap) :Example: >>> start = 3 >>> distmap = AlgPaths.dijkstra_ctx(g, start, lambda _start,_current,_next: (True)) .. py:method:: nctx.undirected.AlgPaths.find_path( (Graph)g, (int)start, (int)target) -> list : Conventional shortest path discovery using Dijkstra's algorithm. :param g: The Graph object :type g: Graph :param start: Source vertex :type start: int :param target: Target vertex :type target: int :return: A list of vertex indices describing the shortest path from start to target. :rtype: list .. py:method:: nctx.undirected.AlgPaths.find_path_ctx( (Graph)g, (int)start, (int)target, (object)decision_fct) -> list : Obtain a shortest paths from a start vertex to a target vertex using Dijkstra's algorithm taking into account contextual constraints. This is basically a wrapper around :py:func:`dijkstra_ctx `. Please see the mentioned function for more information regarding the contextual constraints. :param g: The Graph object :type g: Graph :param decision_fct: The decision function enforcing contextual constraints. The signature of the function is ``(vertex index, vertex index, vertex index) -> Bool`` :type decision_fct: function :param start: Start vertex :type start: int :param target: Target vertex :type target: int :return: A list of vertex indices describing the shortest path from start to target. :rtype: list :Example: >>> start = 3 >>> target = 10 >>> path = AlgPaths.find_path_ctx(g,start,target,lambda _start,_current,_next: (True)) AlgCentralities: Centrality measures ------------------------------------ .. csv-table:: Summary :widths: 20, 50 ":py:func:`AlgCentralities `", "" ":py:func:`betweenness `", "Obtain betweenness centrality for a graph using Brandes' efficient algorithm." ":py:func:`betweenness_ctx `", "Betweenness centrality with dynamic contextual constraints." ":py:func:`closeness `", "Obtain closeness centrality for a graph." ":py:func:`closeness_ctx `", "Closeness centrality with dynamic contextual constraints." .. py:class:: nctx.undirected.AlgCentralities .. py:method:: nctx.undirected.AlgCentralities.betweenness( (Graph)g, (PropertyMapDouble)outmap) -> None : :noindex: .. py:method:: nctx.undirected.AlgCentralities.betweenness( (Graph)g) -> PropertyMapDouble : Obtain betweenness centrality for a graph using Brandes' efficient algorithm. :param g: Graph object :type g: Graph :param outmap: map in which centrality values will be written :type outmap: PropertyMapDouble :return: list of centrality values named betweenness :rtype: PropertyMapDouble :Example: >>> outmap = PropertyMapDouble(g, 'betw') >>> AlgCentralities.betweenness(g, outmap) :Example: >>> outmap = AlgCentralities.betweenness(g) .. py:method:: nctx.undirected.AlgCentralities.betweenness_ctx( (Graph)g, (object)betw_decision_fct, (PropertyMapDouble)outmap) -> None : :noindex: .. py:method:: nctx.undirected.AlgCentralities.betweenness_ctx( (Graph)g, (object)betw_decision_fct) -> PropertyMapDouble : Betweenness centrality with dynamic contextual constraints. Using this function allows obtaining betweenness centrality under dynamic contextual constraints. Enforcement of constraints is the task of the given user-defined function. The function enforcing contextual constraints is evaluated at each node during shortest path traversal. The function needs to evaluate to True or False allowing an edge to be visited or not. As parameters, the current state of the betweenness calculation is passed to the function, i.e. the starting node for which a centrality value is being calculated, the current node, and the descending node in question. If the function returns False, the descending node is not being visited. The three nodes are passed as indices allowing for access of (external) attribute and other associated information. Note that the decision function is evaluated more than once during path traversal. That means, there should not happen any resource-intense computation inside this function. Also, it does not allow to keep track of the status of calculation, e.g. by calculating the visited edges or something similar. If the decision function simply returns True all the time, this function results in the unaltered betweenness centrality values. Obtaining betweenness centrality is based on Brandes' efficient algorithm. At the current stage, the implementation allows for single-core execution only. :param outmap: map in which centrality values will be written :type outmap: PropertyMapDouble :return: list of centrality values named betweenness_constraint :rtype: PropertyMapDouble :Example: >>> outmap = PropertyMapDouble(g, 'betw_ctx') >>> AlgCentralities.betweenness_ctx(g,lambda _start,_current,_next: (True),outmap) :Example: >>> outmap = AlgCentralities.betweenness_ctx(g,lambda _start,_current,_next: (True)) .. py:method:: nctx.undirected.AlgCentralities.closeness( (Graph)g) -> PropertyMapDouble : :noindex: .. py:method:: nctx.undirected.AlgCentralities.closeness( (Graph)g, (PropertyMapDouble)outmap) -> None : Obtain closeness centrality for a graph. :param g: Graph object :type g: Graph :param outmap: map in which centrality values will be written :type outmap: PropertyMapDouble :return: list of centrality values named betweenness :rtype: PropertyMapDouble :Example: >>> outmap = AlgCentralities.closeness(g) :Example: >>> outmap = PropertyMapDouble(g, 'clsn') >>> AlgCentralities.closeness(g, outmap) .. py:method:: nctx.undirected.AlgCentralities.closeness_ctx( (Graph)g, (object)clsn_decision_fct, (PropertyMapDouble)outmap) -> None : :noindex: .. py:method:: nctx.undirected.AlgCentralities.closeness_ctx( (Graph)g, (object)clsn_decision_fct) -> PropertyMapDouble : Closeness centrality with dynamic contextual constraints. Using this function allows obtaining closeness centrality under dynamic contextual constraints. Enforcement of constraints is the task of the given user-defined function. The function enforcing contextual constraints is evaluated at each node during shortest path traversal. The function needs to evaluate to True or False allowing an edge to be visited or not. As parameters, the current state of the centrality calculation is passed to the function, i.e. the starting node for which a centrality value is being calculated, the current node, and the descending node in question. If the function returns False, the descending node is not being visited. The three nodes are passed as indices allowing for access of (external) attribute and other associated information. Note that the decision function is evaluated more than once during path traversal. That means, there should not happen any resource-intense computation inside this function. Also, it does not allow to keep track of the status of calculation, e.g. by calculating the visited edges or something similar. If the decision function simply returns True all the time, this function results in the unaltered betweenness centrality values. :param outmap: map in which centrality values will be written :type outmap: PropertyMapDouble :return: list of centrality values named closeness_constraint :rtype: PropertyMapDouble :Example: >>> outmap = PropertyMapDouble(g, 'clsn_ctx') >>> AlgCentralities.closeness_ctx(g,lambda _start,_current,_next: (True),outmap) :Example: >>> outmap = AlgCentralities.closeness_ctx(g,lambda _start,_current,_next: (True)) Graph Property Maps ------------------- Property maps allow to store attribute information together with the vertices. These are mainly used for importing and exporting graphs: :py:func:`read_graphml ` and :py:func:`write_graphml ` .. todo:: Support edge property maps Property Maps containing atom elements ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. csv-table:: Summary :widths: 20, 50 ":py:class:`PropertyMapDouble `", "PropertyMapDouble serves as a list of atom items of type float." ":py:class:`PropertyMapInt `", "PropertyMapInt serves as a list of atom items of type int." ":py:class:`PropertyMapStr `", "PropertyMapStr serves as a list of atom items of type str." ":py:class:`PropertyMapULong `", "PropertyMapULong serves as a list of atom items of type unsigned long - a number > 0." .. py:class:: nctx.undirected.PropertyMapDouble PropertyMapDouble serves as a list of atom items of type float. The list contains values of a single data type only as this is a link to the C++ code base (and C++ is a strongly typed language). This PropertyMap behaves like a python list, i.e. it allows iteration and supports built-in functions append and extend. The contained data type can be recognized from the class name of the PropertyMap. The PropertyMap can be converted to a Python list or a numpy array easily. :param g: The Graph object :type g: Graph :param name: Name of the PropertyMap :type name: str :param init_val: initial value :type init_val: float :Example: >>> my_map = PropertyMapDouble(g, 'context1') >>> my_map = PropertyMapDouble(g, 'context1', .0) :Example: >>> import numpy as np >>> np_arr = np.array(list(my_map)) .. py:method:: nctx.undirected.PropertyMapDouble.__contains__( (float)arg2) -> bool : Allows to check for the existence of elements in the PropertyMap. :Example: >>> .0 in my_map True >>> .1 in my_map False .. py:method:: nctx.undirected.PropertyMapDouble.__getitem__( (int)arg2) -> float : This allows to access items using square brackets. See :py:func:`get_elem ` for a detailed description of parameters. :Example: >>> _ = my_map[2] .. py:method:: nctx.undirected.PropertyMapDouble.__init__( (object)arg1, (Graph)arg2, (str)arg3) -> None :noindex: .. py:method:: nctx.undirected.PropertyMapDouble.__init__( (object)arg1, (Graph)arg2, (str)arg3, (float)arg4) -> None Not commented yet .. py:method:: nctx.undirected.PropertyMapDouble.__iter__( (object)arg1) -> object Not commented yet .. py:method:: nctx.undirected.PropertyMapDouble.__len__( ) -> int : Allows to retrieve the length of the PropertyMap. :Example: >>> len(my_map) 10 .. py:method:: nctx.undirected.PropertyMapDouble.__next__( ) -> float : Allows to iterater over the PropertyMap. :Example: >>> for ctx in my_map: ... pass .. py:method:: nctx.undirected.PropertyMapDouble.__setitem__( (int)arg2, (float)arg3) -> None : This allows to modify items using square brackets. See :py:func:`set_elem ` for a detailed description of parameters. :Example: >>> my_map[2] = .1 .. py:method:: nctx.undirected.PropertyMapDouble.get_elem( (int)i) -> float : Retrieve the ith element of this list.n :param i: Index of element. :type i: int :return: ith element. :rtype: float .. py:method:: nctx.undirected.PropertyMapDouble.get_name( ) -> str : Retrieve name of the property map. The name is mainly used when exporting the Graph to a file, e.g. using :py:func:`write_graphml `. :return: The name of the list :rtype: string .. py:method:: nctx.undirected.PropertyMapDouble.next( ) -> float : Allows to iterater over the PropertyMap. :Example: >>> for ctx in my_map: ... pass .. py:method:: nctx.undirected.PropertyMapDouble.set_elem( (int)i, (float)newval) -> None : Set the ith element of this list to be newval. Note that the type of newval needs to be float or a type that can be implicitly converted to float. :param i: Index of List :type i: int :param j: Index of element. :type j: int :param newval: The new element. :type newval: float :Example: Note the type conversion (float to int) from the input list to the output of :py:func:`get_elem `. >>> complex_map = PropertyMapDouble(g, 'context') >>> complex_map.set_elem(0, 3) >>> complex_map.get_elem(0) 3.0 .. py:class:: nctx.undirected.PropertyMapInt PropertyMapInt serves as a list of atom items of type int. The list contains values of a single data type only as this is a link to the C++ code base (and C++ is a strongly typed language). This PropertyMap behaves like a python list, i.e. it allows iteration and supports built-in functions append and extend. The contained data type can be recognized from the class name of the PropertyMap. The PropertyMap can be converted to a Python list or a numpy array easily. :param g: The Graph object :type g: Graph :param name: Name of the PropertyMap :type name: str :param init_val: initial value :type init_val: int :Example: >>> my_map = PropertyMapInt(g, 'context1') >>> my_map = PropertyMapInt(g, 'context1', 0) :Example: >>> import numpy as np >>> np_arr = np.array(list(my_map)) .. py:method:: nctx.undirected.PropertyMapInt.__contains__( (int)arg2) -> bool : Allows to check for the existence of elements in the PropertyMap. :Example: >>> 0 in my_map True >>> 1 in my_map False .. py:method:: nctx.undirected.PropertyMapInt.__getitem__( (int)arg2) -> int : This allows to access items using square brackets. See :py:func:`get_elem ` for a detailed description of parameters. :Example: >>> _ = my_map[2] .. py:method:: nctx.undirected.PropertyMapInt.__init__( (object)arg1, (Graph)arg2, (str)arg3) -> None :noindex: .. py:method:: nctx.undirected.PropertyMapInt.__init__( (object)arg1, (Graph)arg2, (str)arg3, (int)arg4) -> None Not commented yet .. py:method:: nctx.undirected.PropertyMapInt.__iter__( (object)arg1) -> object Not commented yet .. py:method:: nctx.undirected.PropertyMapInt.__len__( ) -> int : Allows to retrieve the length of the PropertyMap. :Example: >>> len(my_map) 10 .. py:method:: nctx.undirected.PropertyMapInt.__next__( ) -> int : Allows to iterater over the PropertyMap. :Example: >>> for ctx in my_map: ... pass .. py:method:: nctx.undirected.PropertyMapInt.__setitem__( (int)arg2, (int)arg3) -> None : This allows to modify items using square brackets. See :py:func:`set_elem ` for a detailed description of parameters. :Example: >>> my_map[2] = 1 .. py:method:: nctx.undirected.PropertyMapInt.get_elem( (int)i) -> int : Retrieve the ith element of this list.n :param i: Index of element. :type i: int :return: ith element. :rtype: int .. py:method:: nctx.undirected.PropertyMapInt.get_name( ) -> str : Retrieve name of the property map. The name is mainly used when exporting the Graph to a file, e.g. using :py:func:`write_graphml `. :return: The name of the list :rtype: string .. py:method:: nctx.undirected.PropertyMapInt.next( ) -> int : Allows to iterater over the PropertyMap. :Example: >>> for ctx in my_map: ... pass .. py:method:: nctx.undirected.PropertyMapInt.set_elem( (int)i, (int)newval) -> None : Set the ith element of this list to be newval. Note that the type of newval needs to be int or a type that can be implicitly converted to int. Please see :py:func:`PropertyMapDouble.set_elem ` for an example of type conversion. :param i: Index of List :type i: int :param j: Index of element. :type j: int :param newval: The new element. :type newval: int .. py:class:: nctx.undirected.PropertyMapStr PropertyMapStr serves as a list of atom items of type str. The list contains values of a single data type only as this is a link to the C++ code base (and C++ is a strongly typed language). This PropertyMap behaves like a python list, i.e. it allows iteration and supports built-in functions append and extend. The contained data type can be recognized from the class name of the PropertyMap. The PropertyMap can be converted to a Python list or a numpy array easily. :param g: The Graph object :type g: Graph :param name: Name of the PropertyMap :type name: str :param init_val: initial value :type init_val: str :Example: >>> my_map = PropertyMapStr(g, 'context1') >>> my_map = PropertyMapStr(g, 'context1', '') :Example: >>> import numpy as np >>> np_arr = np.array(list(my_map)) .. py:method:: nctx.undirected.PropertyMapStr.__contains__( (str)arg2) -> bool : Allows to check for the existence of elements in the PropertyMap. :Example: >>> '' in my_map True >>> '1' in my_map False .. py:method:: nctx.undirected.PropertyMapStr.__getitem__( (int)arg2) -> str : This allows to access items using square brackets. See :py:func:`get_elem ` for a detailed description of parameters. :Example: >>> _ = my_map[2] .. py:method:: nctx.undirected.PropertyMapStr.__init__( (object)arg1, (Graph)arg2, (str)arg3) -> None :noindex: .. py:method:: nctx.undirected.PropertyMapStr.__init__( (object)arg1, (Graph)arg2, (str)arg3, (str)arg4) -> None Not commented yet .. py:method:: nctx.undirected.PropertyMapStr.__iter__( (object)arg1) -> object Not commented yet .. py:method:: nctx.undirected.PropertyMapStr.__len__( ) -> int : Allows to retrieve the length of the PropertyMap. :Example: >>> len(my_map) 10 .. py:method:: nctx.undirected.PropertyMapStr.__next__( ) -> str : Allows to iterater over the PropertyMap. :Example: >>> for ctx in my_map: ... pass .. py:method:: nctx.undirected.PropertyMapStr.__setitem__( (int)arg2, (str)arg3) -> None : This allows to modify items using square brackets. See :py:func:`set_elem ` for a detailed description of parameters. :Example: >>> my_map[2] = '1' .. py:method:: nctx.undirected.PropertyMapStr.get_elem( (int)i) -> str : Retrieve the ith element of this list.n :param i: Index of element. :type i: int :return: ith element. :rtype: str .. py:method:: nctx.undirected.PropertyMapStr.get_name( ) -> str : Retrieve name of the property map. The name is mainly used when exporting the Graph to a file, e.g. using :py:func:`write_graphml `. :return: The name of the list :rtype: string .. py:method:: nctx.undirected.PropertyMapStr.next( ) -> str : Allows to iterater over the PropertyMap. :Example: >>> for ctx in my_map: ... pass .. py:method:: nctx.undirected.PropertyMapStr.set_elem( (int)i, (str)newval) -> None : Set the ith element of this list to be newval. Note that the type of newval needs to be str or a type that can be implicitly converted to str. Please see :py:func:`PropertyMapDouble.set_elem ` for an example of type conversion. :param i: Index of List :type i: int :param j: Index of element. :type j: int :param newval: The new element. :type newval: str .. py:class:: nctx.undirected.PropertyMapULong PropertyMapULong serves as a list of atom items of type unsigned long - a number > 0. The list contains values of a single data type only as this is a link to the C++ code base (and C++ is a strongly typed language). This PropertyMap behaves like a python list, i.e. it allows iteration and supports built-in functions append and extend. The contained data type can be recognized from the class name of the PropertyMap. The PropertyMap can be converted to a Python list or a numpy array easily. :param g: The Graph object :type g: Graph :param name: Name of the PropertyMap :type name: str :param init_val: initial value :type init_val: int :Example: >>> my_map = PropertyMapULong(g, 'context1') >>> my_map = PropertyMapULong(g, 'context1', 0) :Example: >>> import numpy as np >>> np_arr = np.array(list(my_map)) .. py:method:: nctx.undirected.PropertyMapULong.__contains__( (int)arg2) -> bool : Allows to check for the existence of elements in the PropertyMap. :Example: >>> 0 in my_map True >>> 1 in my_map False .. py:method:: nctx.undirected.PropertyMapULong.__getitem__( (int)arg2) -> int : This allows to access items using square brackets. See :py:func:`get_elem ` for a detailed description of parameters. :Example: >>> _ = my_map[2] .. py:method:: nctx.undirected.PropertyMapULong.__init__( (object)arg1, (Graph)arg2, (str)arg3) -> None :noindex: .. py:method:: nctx.undirected.PropertyMapULong.__init__( (object)arg1, (Graph)arg2, (str)arg3, (int)arg4) -> None Not commented yet .. py:method:: nctx.undirected.PropertyMapULong.__iter__( (object)arg1) -> object Not commented yet .. py:method:: nctx.undirected.PropertyMapULong.__len__( ) -> int : Allows to retrieve the length of the PropertyMap. :Example: >>> len(my_map) 10 .. py:method:: nctx.undirected.PropertyMapULong.__next__( ) -> int : Allows to iterater over the PropertyMap. :Example: >>> for ctx in my_map: ... pass .. py:method:: nctx.undirected.PropertyMapULong.__setitem__( (int)arg2, (int)arg3) -> None : This allows to modify items using square brackets. See :py:func:`set_elem ` for a detailed description of parameters. :Example: >>> my_map[2] = 1 .. py:method:: nctx.undirected.PropertyMapULong.get_elem( (int)i) -> int : Retrieve the ith element of this list.n :param i: Index of element. :type i: int :return: ith element. :rtype: int .. py:method:: nctx.undirected.PropertyMapULong.get_name( ) -> str : Retrieve name of the property map. The name is mainly used when exporting the Graph to a file, e.g. using :py:func:`write_graphml `. :return: The name of the list :rtype: string .. py:method:: nctx.undirected.PropertyMapULong.next( ) -> int : Allows to iterater over the PropertyMap. :Example: >>> for ctx in my_map: ... pass .. py:method:: nctx.undirected.PropertyMapULong.set_elem( (int)i, (int)newval) -> None : Set the ith element of this list to be newval. Note that the type of newval needs to be int or a type that can be implicitly converted to int. Please see :py:func:`PropertyMapDouble.set_elem ` for an example of type conversion. :param i: Index of List :type i: int :param j: Index of element. :type j: int :param newval: The new element. :type newval: int Property Maps containing list elements ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. csv-table:: Summary :widths: 20, 50 ":py:class:`PropertyMapVecDouble `", "PropertyMapVecDouble serves as a container of lists, i." ":py:class:`PropertyMapVecInt `", "PropertyMapVecInt serves as a container of lists, i." ":py:class:`PropertyMapVecStr `", "PropertyMapVecStr serves as a container of lists, i." ":py:class:`PropertyMapVecULong `", "PropertyMapVecULong serves as a container of lists, i." .. py:class:: nctx.undirected.PropertyMapVecDouble PropertyMapVecDouble serves as a container of lists, i.e. it is a list of lists of float. The nested lists all contain values of a single data type as this is a link to the C++ code base (and C++ is a strongly typed language). This PropertyMap behaves like a python list returning lists as items when iterating over it. The allowed data type can be recognized from the class name of the PropertyMap. The PropertyMap can be converted to a Python list or a numpy array easily. :param g: The Graph object :type g: Graph :param name: Name of the PropertyMap :type name: str :param init_val: initial value for each inner list :type init_val: float :param init_size: size of each inner list. :type init_size: int :Example: >>> my_map = PropertyMapVecDouble(g, 'context1') >>> my_map = PropertyMapVecDouble(g, 'context1', 0.0, 10) :Example: >>> import numpy as np >>> np_arr = np.array([np.array(xi) for xi in my_map]) .. py:method:: nctx.undirected.PropertyMapVecDouble.__contains__( (object)arg2) -> bool : Allows to check for the existence of elements in the PropertyMap. :Example: >>> [.1,.2,.3] in my_map False .. py:method:: nctx.undirected.PropertyMapVecDouble.__getitem__( (int)arg2) -> object : This allows to access items using square brackets. See :py:func:`get_list ` for a detailed description of parameters. :Example: >>> _ = my_map[2] >>> _ = my_map[2][0] .. py:method:: nctx.undirected.PropertyMapVecDouble.__init__( (object)arg1, (Graph)arg2, (str)arg3) -> None :noindex: .. py:method:: nctx.undirected.PropertyMapVecDouble.__init__( (object)arg1, (Graph)arg2, (str)arg3, (float)arg4, (int)arg5) -> None Not commented yet .. py:method:: nctx.undirected.PropertyMapVecDouble.__iter__( (object)arg1) -> object Not commented yet .. py:method:: nctx.undirected.PropertyMapVecDouble.__len__( ) -> int : Allows to retrieve the length of the PropertyMap. :Example: >>> len(my_map) 10 .. py:method:: nctx.undirected.PropertyMapVecDouble.__next__( ) -> object : Allows to iterater over the PropertyMap. :Example: >>> for ctx in my_map: ... pass .. py:method:: nctx.undirected.PropertyMapVecDouble.__setitem__( (int)arg2, (object)arg3) -> None : This allows to modify items using square brackets. See :py:func:`set_list ` for a detailed description of parameters. :Example: >>> my_map[2] = [.1,.2,.3,.4,.5] >>> my_map[2][0] = 42.0 .. py:method:: nctx.undirected.PropertyMapVecDouble.get_elem( (int)i, (int)j) -> float : Retrieve the jth element of ith list. :param i: Index of List :type i: int :param j: Index of element. :type j: int :return: jth element in ith list. :rtype: float .. py:method:: nctx.undirected.PropertyMapVecDouble.get_list( (int)i) -> object : Retrieve the ith list. :param i: Index of List :type i: int :param j: Index of element. :type j: int :return: The list saved at position i. :rtype: PropertyMapVecDouble .. py:method:: nctx.undirected.PropertyMapVecDouble.get_name( ) -> str : Retrieve name of the property map. The name is mainly used when exporting the Graph to a file, e.g. using :py:func:`write_graphml `. :return: The name of the list :rtype: string .. py:method:: nctx.undirected.PropertyMapVecDouble.next( ) -> object : Allows to iterater over the PropertyMap. :Example: >>> for ctx in my_map: ... pass .. py:method:: nctx.undirected.PropertyMapVecDouble.set_elem( (int)i, (int)j, (float)newval) -> None : Set the jth element of ith list. Note that the type of the new element needs to be float or a type that can be implicitly converted to float. :param i: Index of List :type i: int :param j: Index of element. :type j: int :param newval: The new element. :type newval: float :Example: Note the type conversion (float to int) from the input to the output of :py:func:`get_elem `. >>> complex_map = PropertyMapVecDouble(g, 'context') >>> complex_map.set_elem(0, 1, 3) >>> complex_map.get_elem(0,1) 3.0 .. py:method:: nctx.undirected.PropertyMapVecDouble.set_list( (int)i, (object)newlist) -> None : Set the ith list to be newlist. :param i: Index of List :type i: int :param newlist: List to be saved at position i. Note that all items of this list will be converted to float internally. :type newlist: list :Example: Note the type conversion (float to int) from the input list to the output of :py:func:`get_elem `. >>> complex_map = PropertyMapVecDouble(g, 'context') >>> complex_map.set_list(0, [1,2,3,4,5]) >>> complex_map.get_elem(0,2) 3.0 .. py:class:: nctx.undirected.PropertyMapVecInt PropertyMapVecInt serves as a container of lists, i.e. it is a list of lists of int. The nested lists all contain values of a single data type as this is a link to the C++ code base (and C++ is a strongly typed language). This PropertyMap behaves like a python list returning lists as items when iterating over it. The allowed data type can be recognized from the class name of the PropertyMap. The PropertyMap can be converted to a Python list or a numpy array easily. :param g: The Graph object :type g: Graph :param name: Name of the PropertyMap :type name: str :param init_val: initial value for each inner list :type init_val: int :param init_size: size of each inner list. :type init_size: int :Example: >>> my_map = PropertyMapVecInt(g, 'context1') >>> my_map = PropertyMapVecInt(g, 'context1', 0, 10) :Example: >>> import numpy as np >>> np_arr = np.array([np.array(xi) for xi in my_map]) .. py:method:: nctx.undirected.PropertyMapVecInt.__contains__( (object)arg2) -> bool : Allows to check for the existence of elements in the PropertyMap. :Example: >>> [1,2,3] in my_map False .. py:method:: nctx.undirected.PropertyMapVecInt.__getitem__( (int)arg2) -> object : This allows to access items using square brackets. See :py:func:`get_list ` for a detailed description of parameters. :Example: >>> _ = my_map[2] >>> _ = my_map[2][0] .. py:method:: nctx.undirected.PropertyMapVecInt.__init__( (object)arg1, (Graph)arg2, (str)arg3) -> None :noindex: .. py:method:: nctx.undirected.PropertyMapVecInt.__init__( (object)arg1, (Graph)arg2, (str)arg3, (int)arg4, (int)arg5) -> None Not commented yet .. py:method:: nctx.undirected.PropertyMapVecInt.__iter__( (object)arg1) -> object Not commented yet .. py:method:: nctx.undirected.PropertyMapVecInt.__len__( ) -> int : Allows to retrieve the length of the PropertyMap. :Example: >>> len(my_map) 10 .. py:method:: nctx.undirected.PropertyMapVecInt.__next__( ) -> object : Allows to iterater over the PropertyMap. :Example: >>> for ctx in my_map: ... pass .. py:method:: nctx.undirected.PropertyMapVecInt.__setitem__( (int)arg2, (object)arg3) -> None : This allows to modify items using square brackets. See :py:func:`set_list ` for a detailed description of parameters. :Example: >>> my_map[2] = [1,2,3,4,5] >>> my_map[2][0] = 42 .. py:method:: nctx.undirected.PropertyMapVecInt.get_elem( (int)i, (int)j) -> int : Retrieve the jth element of ith list. :param i: Index of List :type i: int :param j: Index of element. :type j: int :return: jth element in ith list. :rtype: int .. py:method:: nctx.undirected.PropertyMapVecInt.get_list( (int)i) -> object : Retrieve the ith list. :param i: Index of List :type i: int :param j: Index of element. :type j: int :return: The list saved at position i. :rtype: PropertyMapVecInt .. py:method:: nctx.undirected.PropertyMapVecInt.get_name( ) -> str : Retrieve name of the property map. The name is mainly used when exporting the Graph to a file, e.g. using :py:func:`write_graphml `. :return: The name of the list :rtype: string .. py:method:: nctx.undirected.PropertyMapVecInt.next( ) -> object : Allows to iterater over the PropertyMap. :Example: >>> for ctx in my_map: ... pass .. py:method:: nctx.undirected.PropertyMapVecInt.set_elem( (int)i, (int)j, (int)newval) -> None : Set the jth element of ith list. Note that the type of the new element needs to be int or a type that can be implicitly converted to int. Please see :py:func:`PropertyMapVecDouble.set_elem ` for an example of type conversion. :param i: Index of List :type i: int :param j: Index of element. :type j: int :param newval: The new element. :type newval: int .. py:method:: nctx.undirected.PropertyMapVecInt.set_list( (int)i, (object)newlist) -> None : Set the ith list to be newlist. Please see :py:func:`PropertyMapVecDouble.set_elem ` for an example of type conversion. :param i: Index of List :type i: int :param newlist: List to be saved at position i. Note that all items of this list will be converted to int internally. :type newlist: list .. py:class:: nctx.undirected.PropertyMapVecStr PropertyMapVecStr serves as a container of lists, i.e. it is a list of lists of str. The nested lists all contain values of a single data type as this is a link to the C++ code base (and C++ is a strongly typed language). This PropertyMap behaves like a python list returning lists as items when iterating over it. The allowed data type can be recognized from the class name of the PropertyMap. The PropertyMap can be converted to a Python list or a numpy array easily. :param g: The Graph object :type g: Graph :param name: Name of the PropertyMap :type name: str :param init_val: initial value for each inner list :type init_val: str :param init_size: size of each inner list. :type init_size: int :Example: >>> my_map = PropertyMapVecStr(g, 'context1') >>> my_map = PropertyMapVecStr(g, 'context1', '', 10) :Example: >>> import numpy as np >>> np_arr = np.array([np.array(xi) for xi in my_map]) .. py:method:: nctx.undirected.PropertyMapVecStr.__contains__( (object)arg2) -> bool : Allows to check for the existence of elements in the PropertyMap. :Example: >>> ['1','2','3'] in my_map False .. py:method:: nctx.undirected.PropertyMapVecStr.__getitem__( (int)arg2) -> object : This allows to access items using square brackets. See :py:func:`get_list ` for a detailed description of parameters. :Example: >>> _ = my_map[2] >>> _ = my_map[2][0] .. py:method:: nctx.undirected.PropertyMapVecStr.__init__( (object)arg1, (Graph)arg2, (str)arg3) -> None :noindex: .. py:method:: nctx.undirected.PropertyMapVecStr.__init__( (object)arg1, (Graph)arg2, (str)arg3, (str)arg4, (int)arg5) -> None Not commented yet .. py:method:: nctx.undirected.PropertyMapVecStr.__iter__( (object)arg1) -> object Not commented yet .. py:method:: nctx.undirected.PropertyMapVecStr.__len__( ) -> int : Allows to retrieve the length of the PropertyMap. :Example: >>> len(my_map) 10 .. py:method:: nctx.undirected.PropertyMapVecStr.__next__( ) -> object : Allows to iterater over the PropertyMap. :Example: >>> for ctx in my_map: ... pass .. py:method:: nctx.undirected.PropertyMapVecStr.__setitem__( (int)arg2, (object)arg3) -> None : This allows to modify items using square brackets. See :py:func:`set_list ` for a detailed description of parameters. :Example: >>> my_map[2] = ['1','2','3','4','5'] >>> my_map[2][0] = '42' .. py:method:: nctx.undirected.PropertyMapVecStr.get_elem( (int)i, (int)j) -> str : Retrieve the jth element of ith list. :param i: Index of List :type i: int :param j: Index of element. :type j: int :return: jth element in ith list. :rtype: str .. py:method:: nctx.undirected.PropertyMapVecStr.get_list( (int)i) -> object : Retrieve the ith list. :param i: Index of List :type i: int :param j: Index of element. :type j: int :return: The list saved at position i. :rtype: PropertyMapVecStr .. py:method:: nctx.undirected.PropertyMapVecStr.get_name( ) -> str : Retrieve name of the property map. The name is mainly used when exporting the Graph to a file, e.g. using :py:func:`write_graphml `. :return: The name of the list :rtype: string .. py:method:: nctx.undirected.PropertyMapVecStr.next( ) -> object : Allows to iterater over the PropertyMap. :Example: >>> for ctx in my_map: ... pass .. py:method:: nctx.undirected.PropertyMapVecStr.set_elem( (int)i, (int)j, (str)newval) -> None : Set the jth element of ith list. Note that the type of the new element needs to be str or a type that can be implicitly converted to str. Please see :py:func:`PropertyMapVecDouble.set_elem ` for an example of type conversion. :param i: Index of List :type i: int :param j: Index of element. :type j: int :param newval: The new element. :type newval: str .. py:method:: nctx.undirected.PropertyMapVecStr.set_list( (int)i, (object)newlist) -> None : Set the ith list to be newlist. Please see :py:func:`PropertyMapVecDouble.set_elem ` for an example of type conversion. :param i: Index of List :type i: int :param newlist: List to be saved at position i. Note that all items of this list will be converted to str internally. :type newlist: list .. py:class:: nctx.undirected.PropertyMapVecULong PropertyMapVecULong serves as a container of lists, i.e. it is a list of lists of unsigned long - numbers > 0. The nested lists all contain values of a single data type as this is a link to the C++ code base (and C++ is a strongly typed language). This PropertyMap behaves like a python list returning lists as items when iterating over it. The allowed data type can be recognized from the class name of the PropertyMap. The PropertyMap can be converted to a Python list or a numpy array easily. :param g: The Graph object :type g: Graph :param name: Name of the PropertyMap :type name: str :param init_val: initial value for each inner list :type init_val: int :param init_size: size of each inner list. :type init_size: int :Example: >>> my_map = PropertyMapVecULong(g, 'context1') >>> my_map = PropertyMapVecULong(g, 'context1', 0, 10) :Example: >>> import numpy as np >>> np_arr = np.array([np.array(xi) for xi in my_map]) .. py:method:: nctx.undirected.PropertyMapVecULong.__contains__( (object)arg2) -> bool : Allows to check for the existence of elements in the PropertyMap. :Example: >>> [1,2,3] in my_map False .. py:method:: nctx.undirected.PropertyMapVecULong.__getitem__( (int)arg2) -> object : This allows to access items using square brackets. See :py:func:`get_list ` for a detailed description of parameters. :Example: >>> _ = my_map[2] >>> _ = my_map[2][0] .. py:method:: nctx.undirected.PropertyMapVecULong.__init__( (object)arg1, (Graph)arg2, (str)arg3) -> None :noindex: .. py:method:: nctx.undirected.PropertyMapVecULong.__init__( (object)arg1, (Graph)arg2, (str)arg3, (int)arg4, (int)arg5) -> None Not commented yet .. py:method:: nctx.undirected.PropertyMapVecULong.__iter__( (object)arg1) -> object Not commented yet .. py:method:: nctx.undirected.PropertyMapVecULong.__len__( ) -> int : Allows to retrieve the length of the PropertyMap. :Example: >>> len(my_map) 10 .. py:method:: nctx.undirected.PropertyMapVecULong.__next__( ) -> object : Allows to iterater over the PropertyMap. :Example: >>> for ctx in my_map: ... pass .. py:method:: nctx.undirected.PropertyMapVecULong.__setitem__( (int)arg2, (object)arg3) -> None : This allows to modify items using square brackets. See :py:func:`set_list ` for a detailed description of parameters. :Example: >>> my_map[2] = [1,2,3,4,5] >>> my_map[2][0] = 42 .. py:method:: nctx.undirected.PropertyMapVecULong.get_elem( (int)i, (int)j) -> int : Retrieve the jth element of ith list. :param i: Index of List :type i: int :param j: Index of element. :type j: int :return: jth element in ith list. :rtype: int .. py:method:: nctx.undirected.PropertyMapVecULong.get_list( (int)i) -> object : Retrieve the ith list. :param i: Index of List :type i: int :param j: Index of element. :type j: int :return: The list saved at position i. :rtype: PropertyMapVecULong .. py:method:: nctx.undirected.PropertyMapVecULong.get_name( ) -> str : Retrieve name of the property map. The name is mainly used when exporting the Graph to a file, e.g. using :py:func:`write_graphml `. :return: The name of the list :rtype: string .. py:method:: nctx.undirected.PropertyMapVecULong.next( ) -> object : Allows to iterater over the PropertyMap. :Example: >>> for ctx in my_map: ... pass .. py:method:: nctx.undirected.PropertyMapVecULong.set_elem( (int)i, (int)j, (int)newval) -> None : Set the jth element of ith list. Note that the type of the new element needs to be int or a type that can be implicitly converted to int. Please see :py:func:`PropertyMapVecDouble.set_elem ` for an example of type conversion. :param i: Index of List :type i: int :param j: Index of element. :type j: int :param newval: The new element. :type newval: int .. py:method:: nctx.undirected.PropertyMapVecULong.set_list( (int)i, (object)newlist) -> None : Set the ith list to be newlist. Please see :py:func:`PropertyMapVecDouble.set_elem ` for an example of type conversion. :param i: Index of List :type i: int :param newlist: List to be saved at position i. Note that all items of this list will be converted to int internally. :type newlist: list Graph I/O: Importing and Exporting to files ------------------------------------------- .. csv-table:: Summary :widths: 20, 50 ":py:func:`read_graphml `", "Reads graph specification from a GraphML file and fills a graph object accordingly." ":py:func:`write_graphml `", "Reads graph specification from a GraphML file and fills a graph object accordingly." .. py:function:: nctx.undirected.read_graphml( (Graph)g, (str)filename, (list)pmaps) -> None : Reads graph specification from a GraphML file and fills a graph object accordingly. You can pass it a list of PropertyMaps to be filled. The names of the PropertyMaps must match the names in the graphml file. Graph properties that are present in the GraphML file but that do not have a matching PropertyMap in pmaps are ignored. See https://en.wikipedia.org/wiki/GraphML for more infos about the file format. :param g: The Graph object :type g: Graph :param filename: Path to a GraphML file :type filename: str :param pmaps: A list of PropertyMaps that will be filled with the graph properties found in the file. :type pmaps: list :Example: >>> import nctx.undirected as nctx >>> g = nctx.Graph() >>> name_map = nctx.PropertyMapStr(g, 'name') >>> context_map = PropertyMapVecDouble(g, 'context') >>> nctx.read_graphml(g, 'bcde.ctx.undir.graphml', [name_map, context_map]) .. py:function:: nctx.undirected.write_graphml( (Graph)g, (str)filename, (list)pmaps) -> None : Reads graph specification from a GraphML file and fills a graph object accordingly. You can pass it a list of PropertyMaps to be filled. The names of the PropertyMaps must match the names in the graphml file. Graph properties that are present in the GraphML file but that do not have a matching PropertyMap in pmaps are ignored. See https://en.wikipedia.org/wiki/GraphML for more infos about the file format. :param g: The Graph object :type g: Graph :param filename: Path to a GraphML file :type filename: str :param pmaps: A list of PropertyMaps that will be filled with the graph properties found in the file. :type pmaps: list :Example: >>> import nctx.undirected as nctx >>> g = nctx.Graph() >>> name_map = nctx.PropertyMapStr(g, 'name') >>> context_map = PropertyMapVecDouble(g, 'context') >>> nctx.read_graphml(g, 'bcde.ctx.undir.graphml', [name_map, context_map]) >>> name_map[3] = 'X' >>> context_map[0][2] = .1337 >>> nctx.write_graphml(g, 'bcde.ctx.undir.modified.graphml', [name_map, context_map]) Helper Classes -------------- .. py:class:: nctx.undirected.Edge This is an internal description of an edge. It can't be instantiated from Python. Just don't bother with it. .. py:class:: nctx.undirected.a_iter_ids This is an internal description of the child-iterator. .. py:method:: nctx.undirected.a_iter_ids.__iter__( (object)arg1) -> object Not commented yet .. py:method:: nctx.undirected.a_iter_ids.__len__( ) -> int Not commented yet .. py:method:: nctx.undirected.a_iter_ids.__next__( ) -> int Not commented yet .. py:method:: nctx.undirected.a_iter_ids.next( ) -> int : See :py:func:`Graph.children ` how to use this to iterate over the children of a node. .. py:class:: nctx.undirected.a_iter_ids_rev This is an internal description of the parents-iterator. .. py:method:: nctx.undirected.a_iter_ids_rev.__iter__( (object)arg1) -> object Not commented yet .. py:method:: nctx.undirected.a_iter_ids_rev.__len__( ) -> int Not commented yet .. py:method:: nctx.undirected.a_iter_ids_rev.__next__( ) -> int Not commented yet .. py:method:: nctx.undirected.a_iter_ids_rev.next( ) -> int : See :py:func:`Graph.parents ` how to use this to iterate over the parents of a node. .. py:class:: nctx.undirected.e_iter_ids This is an internal description of the edges-iterator. .. py:method:: nctx.undirected.e_iter_ids.__iter__( (object)arg1) -> object Not commented yet .. py:method:: nctx.undirected.e_iter_ids.__len__( ) -> int Not commented yet .. py:method:: nctx.undirected.e_iter_ids.__next__( ) -> Edge Not commented yet .. py:method:: nctx.undirected.e_iter_ids.next( ) -> Edge : See :py:func:`Graph.edges ` how to use this to iterate over the edges of a graph. .. py:class:: nctx.undirected.e_iter_ids_in This is an internal description of the in-edges-iterator. .. py:method:: nctx.undirected.e_iter_ids_in.__iter__( (object)arg1) -> object Not commented yet .. py:method:: nctx.undirected.e_iter_ids_in.__len__( ) -> int Not commented yet .. py:method:: nctx.undirected.e_iter_ids_in.__next__( ) -> Edge Not commented yet .. py:method:: nctx.undirected.e_iter_ids_in.next( ) -> Edge : See :py:func:`Graph.edges ` how to use this to iterate over the edges of a graph. .. py:class:: nctx.undirected.e_iter_ids_out This is an internal description of the out-edges-iterator. .. py:method:: nctx.undirected.e_iter_ids_out.__iter__( (object)arg1) -> object Not commented yet .. py:method:: nctx.undirected.e_iter_ids_out.__len__( ) -> int Not commented yet .. py:method:: nctx.undirected.e_iter_ids_out.__next__( ) -> Edge Not commented yet .. py:method:: nctx.undirected.e_iter_ids_out.next( ) -> Edge : See :py:func:`Graph.edges ` how to use this to iterate over the edges of a graph. .. py:class:: nctx.undirected.v_iter_ids This is an internal description of the vertex-iterator. .. py:method:: nctx.undirected.v_iter_ids.__iter__( (object)arg1) -> object Not commented yet .. py:method:: nctx.undirected.v_iter_ids.__len__( ) -> int Not commented yet .. py:method:: nctx.undirected.v_iter_ids.__next__( ) -> int Not commented yet .. py:method:: nctx.undirected.v_iter_ids.next( ) -> int : See :py:func:`Graph.vertices ` how to use this to iterate over the vertices of a graph.