class_docstr: The core class of DeepGraph (dg).
  
  This class encapsulates the graph representation as ``pandas.DataFrame``
  objects in its attributes ``v`` and ``e``. It can be initialized with a
  node table ``v``, whose rows represent the nodes of the graph, as well
  as an edge table ``e``, whose rows represent edges between the nodes.
  
  Given a node table ``v``, it provides methods to iteratively compute
  pairwise relations between the nodes using arbitrary, user-defined
  functions. These methods provide arguments to parallelize the
  computation and control memory consumption (see ``create_edges`` and
  ``create_edges_ft``).
  
  Also provides methods to partition nodes, edges or an entire graph by
  the graph's properties and labels, and to create common network
  representations and graph objects of popular Python network packages.
  
  Furthermore, it provides methods to visualize graphs and their
  properties and to benchmark the graph construction parameters.
  
  Optionally, the convenience parameter ``supernode_labels_by`` can be
  passed, creating supernode labels by enumerating all distinct (tuples
  of) values of a (multiple) column(s) of ``v`` . Superedge labels can be
  created analogously, by passing the parameter ``superedge_labels_by``.
  
  Parameters
  ----------
  v : pandas.DataFrame or pandas.HDFStore, optional (default=None)
      The node table, a table representation of the nodes of a graph. The
      index of ``v`` must be unique and represents the node indices. The
      column names of ``v`` represent the types of features of the nodes,
      and each cell represents a feature of a node. Only a reference to
      the input DataFrame is created, not a copy. May also be a
      ``pandas.HDFStore``, but only ``create_edges`` and
      ``create_edges_ft`` may then be used (so far).
  
  e : pandas.DataFrame, optional (default=None)
      The edge table, a table representation of the edges between the
      nodes given by ``v``. Its index has to be a
      ``pandas.core.index.MultiIndex``, whose first level contains the
      indices of the source nodes, and the second level contains the
      indices of the target nodes. Each row of ``e`` represents an edge,
      column names of ``e`` represent the types of relations of the edges,
      and each cell in ``e`` represents a relation of an edge. Only a
      reference to the input DataFrame is created, not a copy.
  
  supernode_labels_by : dict, optional (default=None)
      A dictionary whose keys are strings and their values are (lists of)
      column names of ``v``. Appends a column to ``v`` for each key, whose
      values correspond to supernode labels, enumerating all distinct
      (tuples of) values of the column(s) given by the dict's value.
  
  superedge_labels_by : dict, optional (default=None)
      A dictionary whose keys are strings and their values are (lists of)
      column names of ``e``. Appends a column to ``e`` for each key, whose
      values correspond to superedge labels enumerating all distinct
      (tuples of) values of the column(s) given by the dict's value.
  
  Attributes
  ----------
  v : pandas.DataFrame
      See Parameters.
  
  e : pandas.DataFrame
      See Parameters.
  
  n : int
      Property: Number of nodes.
  
  m : int
      Property: Number of edges.
  
  f : pd.DataFrame
      Property: types of features and number of features of corresponding
      type.
  
  r : pd.DataFrame
      Property: types of relations and number of relations of
      corresponding type.
class_docstr_tok: ["The","core","class","of","DeepGraph","(","dg",")",".","This","class","encapsulates","the","graph","representation","as","``","pandas.DataFrame","``","objects","in","its","attributes","``","v","``","and","``","e","``",".","It","can","be","initialized","with","a","node","table","``","v","``",",","whose","rows","represent","the","nodes","of","the","graph",",","as","well","as","an","edge","table","``","e","``",",","whose","rows","represent","edges","between","the","nodes",".","Given","a","node","table","``","v","``",",","it","provides","methods","to","iteratively","compute","pairwise","relations","between","the","nodes","using","arbitrary",",","user-defined","functions",".","These","methods","provide","arguments","to","parallelize","the","computation","and","control","memory","consumption","(","see","``","create_edges","``","and","``","create_edges_ft","``",")",".","Also","provides","methods","to","partition","nodes",",","edges","or","an","entire","graph","by","the","graph","'s","properties","and","labels",",","and","to","create","common","network","representations","and","graph","objects","of","popular","Python","network","packages",".","Furthermore",",","it","provides","methods","to","visualize","graphs","and","their","properties","and","to","benchmark","the","graph","construction","parameters",".","Optionally",",","the","convenience","parameter","``","supernode_labels_by","``","can","be","passed",",","creating","supernode","labels","by","enumerating","all","distinct","(","tuples","of",")","values","of","a","(","multiple",")","column","(","s",")","of","``","v","``",".","Superedge","labels","can","be","created","analogously",",","by","passing","the","parameter","``","superedge_labels_by","``",".","Parameters","--","--","--","--","--","v",":","pandas.DataFrame","or","pandas.HDFStore",",","optional","(","default=None",")","The","node","table",",","a","table","representation","of","the","nodes","of","a","graph",".","The","index","of","``","v","``","must","be","unique","and","represents","the","node","indices",".","The","column","names","of","``","v","``","represent","the","types","of","features","of","the","nodes",",","and","each","cell","represents","a","feature","of","a","node",".","Only","a","reference","to","the","input","DataFrame","is","created",",","not","a","copy",".","May","also","be","a","``","pandas.HDFStore","``",",","but","only","``","create_edges","``","and","``","create_edges_ft","``","may","then","be","used","(","so","far",")",".","e",":","pandas.DataFrame",",","optional","(","default=None",")","The","edge","table",",","a","table","representation","of","the","edges","between","the","nodes","given","by","``","v","``",".","Its","index","has","to","be","a","``","pandas.core.index.MultiIndex","``",",","whose","first","level","contains","the","indices","of","the","source","nodes",",","and","the","second","level","contains","the","indices","of","the","target","nodes",".","Each","row","of","``","e","``","represents","an","edge",",","column","names","of","``","e","``","represent","the","types","of","relations","of","the","edges",",","and","each","cell","in","``","e","``","represents","a","relation","of","an","edge",".","Only","a","reference","to","the","input","DataFrame","is","created",",","not","a","copy",".","supernode_labels_by",":","dict",",","optional","(","default=None",")","A","dictionary","whose","keys","are","strings","and","their","values","are","(","lists","of",")","column","names","of","``","v","``",".","Appends","a","column","to","``","v","``","for","each","key",",","whose","values","correspond","to","supernode","labels",",","enumerating","all","distinct","(","tuples","of",")","values","of","the","column","(","s",")","given","by","the","dict","'s","value",".","superedge_labels_by",":","dict",",","optional","(","default=None",")","A","dictionary","whose","keys","are","strings","and","their","values","are","(","lists","of",")","column","names","of","``","e","``",".","Appends","a","column","to","``","e","``","for","each","key",",","whose","values","correspond","to","superedge","labels","enumerating","all","distinct","(","tuples","of",")","values","of","the","column","(","s",")","given","by","the","dict","'s","value",".","Attributes","--","--","--","--","--","v",":","pandas.DataFrame","See","Parameters",".","e",":","pandas.DataFrame","See","Parameters",".","n",":","int","Property",":","Number","of","nodes",".","m",":","int","Property",":","Number","of","edges",".","f",":","pd.DataFrame","Property",":","types","of","features","and","number","of","features","of","corresponding","type",".","r",":","pd.DataFrame","Property",":","types","of","relations","and","number","of","relations","of","corresponding","type","."]
docstr: Return supergraph DataFrames ``sv`` and ``se``.
  
  This method allows partitioning of the  graph represented by ``v`` and
  ``e`` into a supergraph, ``sv`` and ``se``. It creates a (intersection)
  partition of the nodes in ``v`` by the type(s) of feature(s)
  ``features``, together with the (intersection) partition's
  **corresponding** partition of the edges in ``e``.
  
  Essentially, this method is a wrapper around pandas groupby methods:
  ``sv`` = ``v``.groupby(``features``).agg(``feature_funcs``) and
  ``se`` = ``e``.groupby(features_s+features_t).agg(``relation_funcs``).
  In order to group ``e`` by features_s and features_t, the features of
  type ``features`` are transferred to ``e``, appending '_s' and '_t' to
  the corresponding column names of ``e``, indicating source and target
  features, respectively (if they are not already present).
  
  By passing a dictionary of functions on the features (relations) of
  ``v`` (``e``), ``feature_funcs`` (``relation_funcs``), one may
  aggregate user-defined values of the partition's elements, the
  supernodes' (superedges') features (relations). If ``n_nodes``
  (``n_edges``) is True, create a column with the number of each
  supernode's (superedge's) constituent nodes (edges).
  
  If ``return_gve`` is True, return the created groupby objects to
  facilitate additional operations, such as ``gv``.apply(func, *args,
  **kwargs) or ``ge``.apply(func, *args, **kwargs).
  
  For details, type help(``g.v``.groupby), and/or inspect the available
  methods of ``gv``.
  
  For examples, see below. For an in-depth description and mathematical
  details of graph partitioning, see
  https://arxiv.org/pdf/1604.00971v1.pdf, in particular Sec. III C, E
  and F.
  
  Parameters
  ----------
  features : str, int or array_like
      Column name(s) of ``v``, indicating the type(s) of feature(s) used
      to induce a (intersection) partition of ``v``, and its
      **corresponding** partition of the edges in ``e``. Creates pandas
      groupby objects, ``gv`` and ``ge``.
  
  feature_funcs : dict, optional (default=None)
      Each key must be a column name of ``v``, each value either a
      function, or a list of functions, working when passed a
      ``pandas.DataFrame`` or when passed to ``pandas.DataFrame.apply``.
      See the docstring of ``gv``.agg for details: help(``gv``.agg).
  
  relation_funcs : dict, optional (default=None)
      Each key must be a column name of ``e``, each value either a
      function, or a list of functions, working when passed a
      ``pandas.DataFrame`` or when passed to ``pandas.DataFrame.apply``.
      See the docstring of ``ge``.agg for details: help(``ge``.agg).
  
  n_nodes : bool, optional (default=True)
      Whether to create a ``n_nodes`` column in ``sv``, indicating the
      number of nodes in each supernode.
  
  n_edges : bool, optional (default=True)
      Whether to create a ``n_edges`` column in ``se``, indicating the
      number of edges in each superedge.
  
  return_gve : bool, optional (default=False)
      If True, also return the pandas groupby objects, ``gv`` and ``ge``.
  
  Returns
  -------
  sv : pd.DataFrame
      The aggreated DataFrame of supernodes, ``sv``.
  
  se : pd.DataFrame
      The aggregated DataFrame of superedges, ``se``.
  
  gv : pandas.core.groupby.DataFrameGroupBy
      The pandas groupby object, ``v``.groupby(``features``).
  
  ge : pandas.core.groupby.DataFrameGroupBy
      The pandas groupby object, ``e``.groupby(features_i+feaures_j).
  
  See also
  --------
  partition_nodes
  partition_edges
  
  Notes
  -----
  Currently, NA groups in GroupBy are automatically excluded (silently).
  One workaround is to use a placeholder (e.g., -1, 'none') for NA values
  before doing the groupby (calling this method). See
  http://stackoverflow.com/questions/18429491/groupby-columns-with-nan-missing-values
  and https://github.com/pydata/pandas/issues/3729.
  
  Examples
  --------
  First, we need to create a graph in order to demonstrate its
  partitioning into a supergraph.
  
  Create a node table:
  
  >>> import pandas as pd
  >>> import deepgraph as dg
  >>> v = pd.DataFrame({'x': [-3.4,2.1,-1.1,0.9,2.3],
  ...                   'time': [0,1,2,5,9],
  ...                   'color': ['g','g','b','g','r'],
  ...                   'size': [1,3,2,3,1]})
  >>> g = dg.DeepGraph(v)
  
  >>> g.v
    color  size  time    x
  0     g     1     0 -3.4
  1     g     3     1  2.1
  2     b     2     2 -1.1
  3     g     3     5  0.9
  4     r     1     9  2.3
  
  Create an edge table:
  
  >>> def some_relations(ft_r, x_s,x_t,color_s,color_t,size_s,size_t):
  ...     dx = x_t - x_s
  ...     v = dx / ft_r
  ...     same_color = color_s == color_t
  ...     larger_than = size_s > size_t
  ...     return dx, v, same_color, larger_than
  >>> g.create_edges_ft(('time', 5), connectors=some_relations)
  >>> g.e.rename(columns={'ft_r': 'dt'}, inplace=True)
  >>> g.e['inds'] = g.e.index.values  # to ease the eyes
  
  >>> g.e
        dx  dt larger_than same_color         v    inds
  s t
  0 1  5.5   1       False       True  5.500000  (0, 1)
    2  2.3   2       False      False  1.150000  (0, 2)
    3  4.3   5       False       True  0.860000  (0, 3)
  1 2 -3.2   1        True      False -3.200000  (1, 2)
    3 -1.2   4       False       True -0.300000  (1, 3)
  2 3  2.0   3       False      False  0.666667  (2, 3)
  3 4  1.4   4        True      False  0.350000  (3, 4)
  
  Create a supergraph by partitioning by the type of feature 'color':
  
  >>> sv, se = g.partition_graph('color')
  
  >>> sv
         n_nodes
  color
  b            1
  g            3
  r            1
  
  >>> se
                   n_edges
  color_s color_t
  b       g              1
  g       b              2
          g              3
          r              1
  
  Create intersection partitions by the types of features 'color' and
  'size' (which are further refinements of the last partitions):
  
  >>> sv, se = g.partition_graph(
  ...     ['color', 'size'],
  ...     relation_funcs={'inds': lambda x: tuple(x)})
  
  >>> sv
              n_nodes
  color size
  b     2           1
  g     1           1
        3           2
  r     1           1
  
  >>> se
                                 n_edges              inds
  color_s size_s color_t size_t
  b       2      g       3             1         ((2, 3),)
  g       1      b       2             1         ((0, 2),)
                 g       3             2  ((0, 1), (0, 3))
          3      b       2             1         ((1, 2),)
                 g       3             1         ((1, 3),)
                 r       1             1         ((3, 4),)
  
  Partition by 'color' and aggregate some properties:
  
  >>> sv, se = g.partition_graph('color',
  ...     feature_funcs={'time': lambda x: list(x)},
  ...     relation_funcs={'larger_than': 'sum', 'same_color': 'sum'})
  
  >>> sv
         n_nodes       time
  color
  b            1        [2]
  g            3  [0, 1, 5]
  r            1        [9]
  
  >>> se
                   n_edges larger_than  same_color
  color_s color_t
  b       g              1       False           0
  g       b              2        True           0
          g              3       False           3
          r              1        True           0
docstr_tok: ["Return","supergraph","DataFrames","``","sv","``","and","``","se","``",".","This","method","allows","partitioning","of","the","graph","represented","by","``","v","``","and","``","e","``","into","a","supergraph",",","``","sv","``","and","``","se","``",".","It","creates","a","(","intersection",")","partition","of","the","nodes","in","``","v","``","by","the","type","(","s",")","of","feature","(","s",")","``","features","``",",","together","with","the","(","intersection",")","partition's","*","*","corresponding","*","*","partition","of","the","edges","in","``","e","``",".","Essentially",",","this","method","is","a","wrapper","around","pandas","groupby","methods",":","``","sv","``","=","``","v","``",".groupby","(","``","features","``",")",".agg","(","``","feature_funcs","``",")","and","``","se","``","=","``","e","``",".groupby","(","features_s+features_t",")",".agg","(","``","relation_funcs","``",")",".","In","order","to","group","``","e","``","by","features_s","and","features_t",",","the","features","of","type","``","features","``","are","transferred","to","``","e","``",",","appending","'_s","'","and","'_t","'","to","the","corresponding","column","names","of","``","e","``",",","indicating","source","and","target","features",",","respectively","(","if","they","are","not","already","present",")",".","By","passing","a","dictionary","of","functions","on","the","features","(","relations",")","of","``","v","``","(","``","e","``",")",",","``","feature_funcs","``","(","``","relation_funcs","``",")",",","one","may","aggregate","user-defined","values","of","the","partition","'s","elements",",","the","supernodes","'","(","superedges","'",")","features","(","relations",")",".","If","``","n_nodes","``","(","``","n_edges","``",")","is","True",",","create","a","column","with","the","number","of","each","supernode","'s","(","superedge","'s",")","constituent","nodes","(","edges",")",".","If","``","return_gve","``","is","True",",","return","the","created","groupby","objects","to","facilitate","additional","operations",",","such","as","``","gv","``",".apply","(","func",",","*","args",",","*","*","kwargs",")","or","``","ge","``",".apply","(","func",",","*","args",",","*","*","kwargs",")",".","For","details",",","type","help","(","``","g.v","``",".groupby",")",",","and\/or","inspect","the","available","methods","of","``","gv","``",".","For","examples",",","see","below",".","For","an","in-depth","description","and","mathematical","details","of","graph","partitioning",",","see","https",":","\/\/arxiv.org\/pdf\/1604.00971v1.pdf",",","in","particular","Sec",".","III","C",",","E","and","F.","Parameters","--","--","--","--","--","features",":","str",",","int","or","array_like","Column","name","(","s",")","of","``","v","``",",","indicating","the","type","(","s",")","of","feature","(","s",")","used","to","induce","a","(","intersection",")","partition","of","``","v","``",",","and","its","*","*","corresponding","*","*","partition","of","the","edges","in","``","e","``",".","Creates","pandas","groupby","objects",",","``","gv","``","and","``","ge","``",".","feature_funcs",":","dict",",","optional","(","default=None",")","Each","key","must","be","a","column","name","of","``","v","``",",","each","value","either","a","function",",","or","a","list","of","functions",",","working","when","passed","a","``","pandas.DataFrame","``","or","when","passed","to","``","pandas.DataFrame.apply","``",".","See","the","docstring","of","``","gv","``",".agg","for","details",":","help","(","``","gv","``",".agg",")",".","relation_funcs",":","dict",",","optional","(","default=None",")","Each","key","must","be","a","column","name","of","``","e","``",",","each","value","either","a","function",",","or","a","list","of","functions",",","working","when","passed","a","``","pandas.DataFrame","``","or","when","passed","to","``","pandas.DataFrame.apply","``",".","See","the","docstring","of","``","ge","``",".agg","for","details",":","help","(","``","ge","``",".agg",")",".","n_nodes",":","bool",",","optional","(","default=True",")","Whether","to","create","a","``","n_nodes","``","column","in","``","sv","``",",","indicating","the","number","of","nodes","in","each","supernode",".","n_edges",":","bool",",","optional","(","default=True",")","Whether","to","create","a","``","n_edges","``","column","in","``","se","``",",","indicating","the","number","of","edges","in","each","superedge",".","return_gve",":","bool",",","optional","(","default=False",")","If","True",",","also","return","the","pandas","groupby","objects",",","``","gv","``","and","``","ge","``",".","Returns","--","--","--","-","sv",":","pd.DataFrame","The","aggreated","DataFrame","of","supernodes",",","``","sv","``",".","se",":","pd.DataFrame","The","aggregated","DataFrame","of","superedges",",","``","se","``",".","gv",":","pandas.core.groupby.DataFrameGroupBy","The","pandas","groupby","object",",","``","v","``",".groupby","(","``","features","``",")",".","ge",":","pandas.core.groupby.DataFrameGroupBy","The","pandas","groupby","object",",","``","e","``",".groupby","(","features_i+feaures_j",")",".","See","also","--","--","--","--","partition_nodes","partition_edges","Notes","--","--","-","Currently",",","NA","groups","in","GroupBy","are","automatically","excluded","(","silently",")",".","One","workaround","is","to","use","a","placeholder","(","e.g.",",","-1",",","'none","'",")","for","NA","values","before","doing","the","groupby","(","calling","this","method",")",".","See","http",":","\/\/stackoverflow.com\/questions\/18429491\/groupby-columns-with-nan-missing-values","and","https",":","\/\/github.com\/pydata\/pandas\/issues\/3729",".","Examples","--","--","--","--","First",",","we","need","to","create","a","graph","in","order","to","demonstrate","its","partitioning","into","a","supergraph",".","Create","a","node","table",":",">",">",">","import","pandas","as","pd",">",">",">","import","deepgraph","as","dg",">",">",">","v","=","pd.DataFrame","(","{","'","x","'",":","[","-3.4,2.1",",","-1.1,0.9,2.3","]",",","...","'time","'",":","[","0,1,2,5,9","]",",","...","'color","'",":","[","'","g","'",",","'","g","'",",","'","b","'",",","'","g","'",",","'","r","'","]",",","...","'size","'",":","[","1,3,2,3,1","]","}",")",">",">",">","g","=","dg.DeepGraph","(","v",")",">",">",">","g.v","color","size","time","x","0","g","1","0","-3.4","1","g","3","1","2.1","2","b","2","2","-1.1","3","g","3","5","0.9","4","r","1","9","2.3","Create","an","edge","table",":",">",">",">","def","some_relations","(","ft_r",",","x_s",",","x_t",",","color_s",",","color_t",",","size_s",",","size_t",")",":","...","dx","=","x_t","-","x_s","...","v","=","dx","\/","ft_r","...","same_color","=","color_s","==","color_t","...","larger_than","=","size_s",">","size_t","...","return","dx",",","v",",","same_color",",","larger_than",">",">",">","g.create_edges_ft","(","(","'time","'",",","5",")",",","connectors=some_relations",")",">",">",">","g.e.rename","(","columns=","{","'ft_r","'",":","'dt","'","}",",","inplace=True",")",">",">",">","g.e","[","'inds","'","]","=","g.e.index.values","#","to","ease","the","eyes",">",">",">","g.e","dx","dt","larger_than","same_color","v","inds","s","t","0","1","5.5","1","False","True","5.500000","(","0",",","1",")","2","2.3","2","False","False","1.150000","(","0",",","2",")","3","4.3","5","False","True","0.860000","(","0",",","3",")","1","2","-3.2","1","True","False","-3.200000","(","1",",","2",")","3","-1.2","4","False","True","-0.300000","(","1",",","3",")","2","3","2.0","3","False","False","0.666667","(","2",",","3",")","3","4","1.4","4","True","False","0.350000","(","3",",","4",")","Create","a","supergraph","by","partitioning","by","the","type","of","feature","'color","'",":",">",">",">","sv",",","se","=","g.partition_graph","(","'color","'",")",">",">",">","sv","n_nodes","color","b","1","g","3","r","1",">",">",">","se","n_edges","color_s","color_t","b","g","1","g","b","2","g","3","r","1","Create","intersection","partitions","by","the","types","of","features","'color","'","and","'size","'","(","which","are","further","refinements","of","the","last","partitions",")",":",">",">",">","sv",",","se","=","g.partition_graph","(","...","[","'color","'",",","'size","'","]",",","...","relation_funcs=","{","'inds","'",":","lambda","x",":","tuple","(","x",")","}",")",">",">",">","sv","n_nodes","color","size","b","2","1","g","1","1","3","2","r","1","1",">",">",">","se","n_edges","inds","color_s","size_s","color_t","size_t","b","2","g","3","1","(","(","2",",","3",")",",",")","g","1","b","2","1","(","(","0",",","2",")",",",")","g","3","2","(","(","0",",","1",")",",","(","0",",","3",")",")","3","b","2","1","(","(","1",",","2",")",",",")","g","3","1","(","(","1",",","3",")",",",")","r","1","1","(","(","3",",","4",")",",",")","Partition","by","'color","'","and","aggregate","some","properties",":",">",">",">","sv",",","se","=","g.partition_graph","(","'color","'",",","...","feature_funcs=","{","'time","'",":","lambda","x",":","list","(","x",")","}",",","...","relation_funcs=","{","'larger_than","'",":","'sum","'",",","'same_color","'",":","'sum","'","}",")",">",">",">","sv","n_nodes","time","color","b","1","[","2","]","g","3","[","0",",","1",",","5","]","r","1","[","9","]",">",">",">","se","n_edges","larger_than","same_color","color_s","color_t","b","g","1","False","0","g","b","2","True","0","g","3","False","3","r","1","True","0"]
code: def partition_graph(
      self,
      features,
      feature_funcs=None,
      relation_funcs=None,
      n_nodes=True,
      n_edges=True,
      return_gve=False,
  ):
      """Return supergraph DataFrames ``sv`` and ``se``.
  
      This method allows partitioning of the  graph represented by ``v`` and
      ``e`` into a supergraph, ``sv`` and ``se``. It creates a (intersection)
      partition of the nodes in ``v`` by the type(s) of feature(s)
      ``features``, together with the (intersection) partition's
      **corresponding** partition of the edges in ``e``.
  
      Essentially, this method is a wrapper around pandas groupby methods:
      ``sv`` = ``v``.groupby(``features``).agg(``feature_funcs``) and
      ``se`` = ``e``.groupby(features_s+features_t).agg(``relation_funcs``).
      In order to group ``e`` by features_s and features_t, the features of
      type ``features`` are transferred to ``e``, appending '_s' and '_t' to
      the corresponding column names of ``e``, indicating source and target
      features, respectively (if they are not already present).
  
      By passing a dictionary of functions on the features (relations) of
      ``v`` (``e``), ``feature_funcs`` (``relation_funcs``), one may
      aggregate user-defined values of the partition's elements, the
      supernodes' (superedges') features (relations). If ``n_nodes``
      (``n_edges``) is True, create a column with the number of each
      supernode's (superedge's) constituent nodes (edges).
  
      If ``return_gve`` is True, return the created groupby objects to
      facilitate additional operations, such as ``gv``.apply(func, *args,
      **kwargs) or ``ge``.apply(func, *args, **kwargs).
  
      For details, type help(``g.v``.groupby), and/or inspect the available
      methods of ``gv``.
  
      For examples, see below. For an in-depth description and mathematical
      details of graph partitioning, see
      https://arxiv.org/pdf/1604.00971v1.pdf, in particular Sec. III C, E
      and F.
  
      Parameters
      ----------
      features : str, int or array_like
          Column name(s) of ``v``, indicating the type(s) of feature(s) used
          to induce a (intersection) partition of ``v``, and its
          **corresponding** partition of the edges in ``e``. Creates pandas
          groupby objects, ``gv`` and ``ge``.
  
      feature_funcs : dict, optional (default=None)
          Each key must be a column name of ``v``, each value either a
          function, or a list of functions, working when passed a
          ``pandas.DataFrame`` or when passed to ``pandas.DataFrame.apply``.
          See the docstring of ``gv``.agg for details: help(``gv``.agg).
  
      relation_funcs : dict, optional (default=None)
          Each key must be a column name of ``e``, each value either a
          function, or a list of functions, working when passed a
          ``pandas.DataFrame`` or when passed to ``pandas.DataFrame.apply``.
          See the docstring of ``ge``.agg for details: help(``ge``.agg).
  
      n_nodes : bool, optional (default=True)
          Whether to create a ``n_nodes`` column in ``sv``, indicating the
          number of nodes in each supernode.
  
      n_edges : bool, optional (default=True)
          Whether to create a ``n_edges`` column in ``se``, indicating the
          number of edges in each superedge.
  
      return_gve : bool, optional (default=False)
          If True, also return the pandas groupby objects, ``gv`` and ``ge``.
  
      Returns
      -------
      sv : pd.DataFrame
          The aggreated DataFrame of supernodes, ``sv``.
  
      se : pd.DataFrame
          The aggregated DataFrame of superedges, ``se``.
  
      gv : pandas.core.groupby.DataFrameGroupBy
          The pandas groupby object, ``v``.groupby(``features``).
  
      ge : pandas.core.groupby.DataFrameGroupBy
          The pandas groupby object, ``e``.groupby(features_i+feaures_j).
  
      See also
      --------
      partition_nodes
      partition_edges
  
      Notes
      -----
      Currently, NA groups in GroupBy are automatically excluded (silently).
      One workaround is to use a placeholder (e.g., -1, 'none') for NA values
      before doing the groupby (calling this method). See
      http://stackoverflow.com/questions/18429491/groupby-columns-with-nan-missing-values
      and https://github.com/pydata/pandas/issues/3729.
  
      Examples
      --------
      First, we need to create a graph in order to demonstrate its
      partitioning into a supergraph.
  
      Create a node table:
  
      >>> import pandas as pd
      >>> import deepgraph as dg
      >>> v = pd.DataFrame({'x': [-3.4,2.1,-1.1,0.9,2.3],
      ...                   'time': [0,1,2,5,9],
      ...                   'color': ['g','g','b','g','r'],
      ...                   'size': [1,3,2,3,1]})
      >>> g = dg.DeepGraph(v)
  
      >>> g.v
        color  size  time    x
      0     g     1     0 -3.4
      1     g     3     1  2.1
      2     b     2     2 -1.1
      3     g     3     5  0.9
      4     r     1     9  2.3
  
      Create an edge table:
  
      >>> def some_relations(ft_r, x_s,x_t,color_s,color_t,size_s,size_t):
      ...     dx = x_t - x_s
      ...     v = dx / ft_r
      ...     same_color = color_s == color_t
      ...     larger_than = size_s > size_t
      ...     return dx, v, same_color, larger_than
      >>> g.create_edges_ft(('time', 5), connectors=some_relations)
      >>> g.e.rename(columns={'ft_r': 'dt'}, inplace=True)
      >>> g.e['inds'] = g.e.index.values  # to ease the eyes
  
      >>> g.e
            dx  dt larger_than same_color         v    inds
      s t
      0 1  5.5   1       False       True  5.500000  (0, 1)
        2  2.3   2       False      False  1.150000  (0, 2)
        3  4.3   5       False       True  0.860000  (0, 3)
      1 2 -3.2   1        True      False -3.200000  (1, 2)
        3 -1.2   4       False       True -0.300000  (1, 3)
      2 3  2.0   3       False      False  0.666667  (2, 3)
      3 4  1.4   4        True      False  0.350000  (3, 4)
  
      Create a supergraph by partitioning by the type of feature 'color':
  
      >>> sv, se = g.partition_graph('color')
  
      >>> sv
             n_nodes
      color
      b            1
      g            3
      r            1
  
      >>> se
                       n_edges
      color_s color_t
      b       g              1
      g       b              2
              g              3
              r              1
  
      Create intersection partitions by the types of features 'color' and
      'size' (which are further refinements of the last partitions):
  
      >>> sv, se = g.partition_graph(
      ...     ['color', 'size'],
      ...     relation_funcs={'inds': lambda x: tuple(x)})
  
      >>> sv
                  n_nodes
      color size
      b     2           1
      g     1           1
            3           2
      r     1           1
  
      >>> se
                                     n_edges              inds
      color_s size_s color_t size_t
      b       2      g       3             1         ((2, 3),)
      g       1      b       2             1         ((0, 2),)
                     g       3             2  ((0, 1), (0, 3))
              3      b       2             1         ((1, 2),)
                     g       3             1         ((1, 3),)
                     r       1             1         ((3, 4),)
  
      Partition by 'color' and aggregate some properties:
  
      >>> sv, se = g.partition_graph('color',
      ...     feature_funcs={'time': lambda x: list(x)},
      ...     relation_funcs={'larger_than': 'sum', 'same_color': 'sum'})
  
      >>> sv
             n_nodes       time
      color
      b            1        [2]
      g            3  [0, 1, 5]
      r            1        [9]
  
      >>> se
                       n_edges larger_than  same_color
      color_s color_t
      b       g              1       False           0
      g       b              2        True           0
              g              3       False           3
              r              1        True           0
  
      """
  
      gv = self.v.groupby(features)
      sv = _aggregate_super_table(
          funcs=feature_funcs, size=n_nodes, gt=gv
      )
      if n_nodes:
          sv.rename(columns={"size": "n_nodes"}, inplace=True)
  
      # transfer feature columns to g.e, for fast groupby
      cols_s = []
      cols_t = []
      if not _is_array_like(features):
          features = [features]
      for col in features:
          cols_s.append(col + "_s")
          cols_t.append(col + "_t")
          if col + "_s" not in self.e.columns:
              s = self.e.index.get_level_values(0)
              self.e.loc[:, col + "_s"] = self.v.loc[s, col].values
          if col + "_t" not in self.e.columns:
              t = self.e.index.get_level_values(1)
              self.e.loc[:, col + "_t"] = self.v.loc[t, col].values
  
      ge = self.e.groupby(cols_s + cols_t)
      se = _aggregate_super_table(
          funcs=relation_funcs, size=n_edges, gt=ge
      )
      if n_edges:
          se = se.rename(columns={"size": "n_edges"})
  
      if return_gve:
          return sv, se, gv, ge
      else:
          return sv, se
  
imports: import inspect
  import os
  from datetime import datetime
  from itertools import chain
  from deepgraph.iterators_and_indexers import _matrix_iterator, _ft_iterator, _iter_edges, _initiate_create_edges, _aggregate_super_table
  from deepgraph.utils import _is_array_like, _dic_translator, _create_bin_edges, _flatten
  import numpy
  import pandas
label_desc: Use image node_id 8 for calling the DeepGraph obj's underlying member method code with example usage: obj.partition_graph(features, feature_funcs, relation_funcs, n_nodes, n_edges, return_gve) and returns: sv,  se,  gv,  ge, sv,  se