You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

pygraph.utils.html 55 kB

5 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816
  1. <!DOCTYPE html>
  2. <!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
  3. <!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
  4. <head>
  5. <meta charset="utf-8">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <title>pygraph.utils package &mdash; py-graph documentation</title>
  8. <script type="text/javascript" src="_static/js/modernizr.min.js"></script>
  9. <script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
  10. <script type="text/javascript" src="_static/jquery.js"></script>
  11. <script type="text/javascript" src="_static/underscore.js"></script>
  12. <script type="text/javascript" src="_static/doctools.js"></script>
  13. <script async="async" type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
  14. <script type="text/javascript" src="_static/js/theme.js"></script>
  15. <link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
  16. <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
  17. <link rel="index" title="Index" href="genindex.html" />
  18. <link rel="search" title="Search" href="search.html" />
  19. </head>
  20. <body class="wy-body-for-nav">
  21. <div class="wy-grid-for-nav">
  22. <nav data-toggle="wy-nav-shift" class="wy-nav-side">
  23. <div class="wy-side-scroll">
  24. <div class="wy-side-nav-search" >
  25. <a href="index.html" class="icon icon-home"> py-graph
  26. </a>
  27. <div class="version">
  28. 1.0
  29. </div>
  30. <div role="search">
  31. <form id="rtd-search-form" class="wy-form" action="search.html" method="get">
  32. <input type="text" name="q" placeholder="Search docs" />
  33. <input type="hidden" name="check_keywords" value="yes" />
  34. <input type="hidden" name="area" value="default" />
  35. </form>
  36. </div>
  37. </div>
  38. <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
  39. <!-- Local TOC -->
  40. <div class="local-toc"><ul>
  41. <li><a class="reference internal" href="#">pygraph.utils package</a><ul>
  42. <li><a class="reference internal" href="#submodules">Submodules</a></li>
  43. <li><a class="reference internal" href="#module-pygraph.utils.graphdataset">pygraph.utils.graphdataset module</a></li>
  44. <li><a class="reference internal" href="#module-pygraph.utils.graphfiles">pygraph.utils.graphfiles module</a></li>
  45. <li><a class="reference internal" href="#pygraph-utils-ipython-log-module">pygraph.utils.ipython_log module</a></li>
  46. <li><a class="reference internal" href="#module-pygraph.utils.isNotebook">pygraph.utils.isNotebook module</a></li>
  47. <li><a class="reference internal" href="#module-pygraph.utils.kernels">pygraph.utils.kernels module</a></li>
  48. <li><a class="reference internal" href="#module-pygraph.utils.logger2file">pygraph.utils.logger2file module</a></li>
  49. <li><a class="reference internal" href="#module-pygraph.utils.model_selection_precomputed">pygraph.utils.model_selection_precomputed module</a></li>
  50. <li><a class="reference internal" href="#module-pygraph.utils.parallel">pygraph.utils.parallel module</a></li>
  51. <li><a class="reference internal" href="#module-pygraph.utils.trie">pygraph.utils.trie module</a></li>
  52. <li><a class="reference internal" href="#module-pygraph.utils.utils">pygraph.utils.utils module</a></li>
  53. <li><a class="reference internal" href="#module-pygraph.utils">Module contents</a></li>
  54. </ul>
  55. </li>
  56. </ul>
  57. </div>
  58. </div>
  59. </div>
  60. </nav>
  61. <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
  62. <nav class="wy-nav-top" aria-label="top navigation">
  63. <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
  64. <a href="index.html">py-graph</a>
  65. </nav>
  66. <div class="wy-nav-content">
  67. <div class="rst-content">
  68. <div role="navigation" aria-label="breadcrumbs navigation">
  69. <ul class="wy-breadcrumbs">
  70. <li><a href="index.html">Docs</a> &raquo;</li>
  71. <li>pygraph.utils package</li>
  72. <li class="wy-breadcrumbs-aside">
  73. <a href="_sources/pygraph.utils.rst.txt" rel="nofollow"> View page source</a>
  74. </li>
  75. </ul>
  76. <hr/>
  77. </div>
  78. <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
  79. <div itemprop="articleBody">
  80. <div class="section" id="pygraph-utils-package">
  81. <h1>pygraph.utils package<a class="headerlink" href="#pygraph-utils-package" title="Permalink to this headline">¶</a></h1>
  82. <div class="section" id="submodules">
  83. <h2>Submodules<a class="headerlink" href="#submodules" title="Permalink to this headline">¶</a></h2>
  84. </div>
  85. <div class="section" id="module-pygraph.utils.graphdataset">
  86. <span id="pygraph-utils-graphdataset-module"></span><h2>pygraph.utils.graphdataset module<a class="headerlink" href="#module-pygraph.utils.graphdataset" title="Permalink to this headline">¶</a></h2>
  87. <p>Obtain all kinds of attributes of a graph dataset.</p>
  88. <dl class="function">
  89. <dt id="pygraph.utils.graphdataset.get_dataset_attributes">
  90. <code class="descclassname">pygraph.utils.graphdataset.</code><code class="descname">get_dataset_attributes</code><span class="sig-paren">(</span><em>Gn</em>, <em>target=None</em>, <em>attr_names=[]</em>, <em>node_label=None</em>, <em>edge_label=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygraph/utils/graphdataset.html#get_dataset_attributes"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.graphdataset.get_dataset_attributes" title="Permalink to this definition">¶</a></dt>
  91. <dd><p>Returns the structure and property information of the graph dataset Gn.</p>
  92. <dl class="docutils">
  93. <dt>Gn <span class="classifier-delimiter">:</span> <span class="classifier">List of NetworkX graph</span></dt>
  94. <dd>List of graphs whose information will be returned.</dd>
  95. <dt>target <span class="classifier-delimiter">:</span> <span class="classifier">list</span></dt>
  96. <dd>The list of classification targets corresponding to Gn. Only works for
  97. classification problems.</dd>
  98. <dt>attr_names <span class="classifier-delimiter">:</span> <span class="classifier">list</span></dt>
  99. <dd><p class="first">List of strings which indicate which informations will be returned. The
  100. possible choices includes:
  101. ‘substructures’: sub-structures Gn contains, including ‘linear’, ‘non</p>
  102. <blockquote>
  103. <div>linear’ and ‘cyclic’.</div></blockquote>
  104. <p>‘node_labeled’: whether vertices have symbolic labels.
  105. ‘edge_labeled’: whether egdes have symbolic labels.
  106. ‘is_directed’: whether graphs in Gn are directed.
  107. ‘dataset_size’: number of graphs in Gn.
  108. ‘ave_node_num’: average number of vertices of graphs in Gn.
  109. ‘min_node_num’: minimum number of vertices of graphs in Gn.
  110. ‘max_node_num’: maximum number of vertices of graphs in Gn.
  111. ‘ave_edge_num’: average number of edges of graphs in Gn.
  112. ‘min_edge_num’: minimum number of edges of graphs in Gn.
  113. ‘max_edge_num’: maximum number of edges of graphs in Gn.
  114. ‘ave_node_degree’: average vertex degree of graphs in Gn.
  115. ‘min_node_degree’: minimum vertex degree of graphs in Gn.
  116. ‘max_node_degree’: maximum vertex degree of graphs in Gn.
  117. ‘ave_fill_factor’: average fill factor (number_of_edges /</p>
  118. <blockquote>
  119. <div>(number_of_nodes ** 2)) of graphs in Gn.</div></blockquote>
  120. <p>‘min_fill_factor’: minimum fill factor of graphs in Gn.
  121. ‘max_fill_factor’: maximum fill factor of graphs in Gn.
  122. ‘node_label_num’: number of symbolic vertex labels.
  123. ‘edge_label_num’: number of symbolic edge labels.
  124. ‘node_attr_dim’: number of dimensions of non-symbolic vertex labels.</p>
  125. <blockquote>
  126. <div>Extracted from the ‘attributes’ attribute of graph nodes.</div></blockquote>
  127. <dl class="last docutils">
  128. <dt>‘edge_attr_dim’: number of dimensions of non-symbolic edge labels.</dt>
  129. <dd>Extracted from the ‘attributes’ attribute of graph edges.</dd>
  130. <dt>‘class_number’: number of classes. Only available for classification </dt>
  131. <dd>problems.</dd>
  132. </dl>
  133. </dd>
  134. <dt>node_label <span class="classifier-delimiter">:</span> <span class="classifier">string</span></dt>
  135. <dd>Node attribute used as label. The default node label is atom. Mandatory
  136. when ‘node_labeled’ or ‘node_label_num’ is required.</dd>
  137. <dt>edge_label <span class="classifier-delimiter">:</span> <span class="classifier">string</span></dt>
  138. <dd>Edge attribute used as label. The default edge label is bond_type.
  139. Mandatory when ‘edge_labeled’ or ‘edge_label_num’ is required.</dd>
  140. </dl>
  141. <dl class="docutils">
  142. <dt>attrs <span class="classifier-delimiter">:</span> <span class="classifier">dict</span></dt>
  143. <dd>Value for each property.</dd>
  144. </dl>
  145. </dd></dl>
  146. </div>
  147. <div class="section" id="module-pygraph.utils.graphfiles">
  148. <span id="pygraph-utils-graphfiles-module"></span><h2>pygraph.utils.graphfiles module<a class="headerlink" href="#module-pygraph.utils.graphfiles" title="Permalink to this headline">¶</a></h2>
  149. <p>Utilities function to manage graph files</p>
  150. <dl class="function">
  151. <dt id="pygraph.utils.graphfiles.loadCT">
  152. <code class="descclassname">pygraph.utils.graphfiles.</code><code class="descname">loadCT</code><span class="sig-paren">(</span><em>filename</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygraph/utils/graphfiles.html#loadCT"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.graphfiles.loadCT" title="Permalink to this definition">¶</a></dt>
  153. <dd><p>load data from a Chemical Table (.ct) file.</p>
  154. <p>a typical example of data in .ct is like this:</p>
  155. <blockquote>
  156. <div><dl class="docutils">
  157. <dt>3 2 &lt;- number of nodes and edges</dt>
  158. <dd><blockquote class="first">
  159. <div>0.0000 0.0000 0.0000 C &lt;- each line describes a node (x,y,z + label)
  160. 0.0000 0.0000 0.0000 C
  161. 0.0000 0.0000 0.0000 O</div></blockquote>
  162. <p class="last">1 3 1 1 &lt;- each line describes an edge : to, from, bond type, bond stereo
  163. 2 3 1 1</p>
  164. </dd>
  165. </dl>
  166. </div></blockquote>
  167. <p>Check <a class="reference external" href="https://www.google.com/url?sa=t&amp;rct=j&amp;q=&amp;esrc=s&amp;source=web&amp;cd=10&amp;ved=2ahUKEwivhaSdjsTlAhVhx4UKHczHA8gQFjAJegQIARAC&amp;url=https%3A%2F%2Fwww.daylight.com%2Fmeetings%2Fmug05%2FKappler%2Fctfile.pdf&amp;usg=AOvVaw1cDNrrmMClkFPqodlF2inS">https://www.google.com/url?sa=t&amp;rct=j&amp;q=&amp;esrc=s&amp;source=web&amp;cd=10&amp;ved=2ahUKEwivhaSdjsTlAhVhx4UKHczHA8gQFjAJegQIARAC&amp;url=https%3A%2F%2Fwww.daylight.com%2Fmeetings%2Fmug05%2FKappler%2Fctfile.pdf&amp;usg=AOvVaw1cDNrrmMClkFPqodlF2inS</a>
  168. for detailed format discription.</p>
  169. </dd></dl>
  170. <dl class="function">
  171. <dt id="pygraph.utils.graphfiles.loadDataset">
  172. <code class="descclassname">pygraph.utils.graphfiles.</code><code class="descname">loadDataset</code><span class="sig-paren">(</span><em>filename</em>, <em>filename_y=None</em>, <em>extra_params=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygraph/utils/graphfiles.html#loadDataset"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.graphfiles.loadDataset" title="Permalink to this definition">¶</a></dt>
  173. <dd><p>Read graph data from filename and load them as NetworkX graphs.</p>
  174. <dl class="docutils">
  175. <dt>filename <span class="classifier-delimiter">:</span> <span class="classifier">string</span></dt>
  176. <dd>The name of the file from where the dataset is read.</dd>
  177. <dt>filename_y <span class="classifier-delimiter">:</span> <span class="classifier">string</span></dt>
  178. <dd>The name of file of the targets corresponding to graphs.</dd>
  179. <dt>extra_params <span class="classifier-delimiter">:</span> <span class="classifier">dict</span></dt>
  180. <dd>Extra parameters only designated to ‘.mat’ format.</dd>
  181. </dl>
  182. <p>data : List of NetworkX graph.
  183. y : List</p>
  184. <blockquote>
  185. <div>Targets corresponding to graphs.</div></blockquote>
  186. <p>This function supports following graph dataset formats:
  187. ‘ds’: load data from .ds file. See comments of function loadFromDS for a example.
  188. ‘cxl’: load data from Graph eXchange Language file (.cxl file). See</p>
  189. <blockquote>
  190. <div><a class="reference external" href="http://www.gupro.de/GXL/Introduction/background.html">http://www.gupro.de/GXL/Introduction/background.html</a>, 2019 for detail.</div></blockquote>
  191. <dl class="docutils">
  192. <dt>‘sdf’: load data from structured data file (.sdf file). See </dt>
  193. <dd><a class="reference external" href="http://www.nonlinear.com/progenesis/sdf-studio/v0.9/faq/sdf-file-format-guidance.aspx">http://www.nonlinear.com/progenesis/sdf-studio/v0.9/faq/sdf-file-format-guidance.aspx</a>,
  194. 2018 for details.</dd>
  195. <dt>‘mat’: Load graph data from a MATLAB (up to version 7.1) .mat file. See</dt>
  196. <dd>README in downloadable file in <a class="reference external" href="http://mlcb.is.tuebingen.mpg.de/Mitarbeiter/Nino/WL/">http://mlcb.is.tuebingen.mpg.de/Mitarbeiter/Nino/WL/</a>,
  197. 2018 for details.</dd>
  198. <dt>‘txt’: Load graph data from a special .txt file. See</dt>
  199. <dd><a class="reference external" href="https://ls11-www.cs.tu-dortmund.de/staff/morris/graphkerneldatasets">https://ls11-www.cs.tu-dortmund.de/staff/morris/graphkerneldatasets</a>,
  200. 2019 for details. Note here filename is the name of either .txt file in
  201. the dataset directory.</dd>
  202. </dl>
  203. </dd></dl>
  204. <dl class="function">
  205. <dt id="pygraph.utils.graphfiles.loadFromDS">
  206. <code class="descclassname">pygraph.utils.graphfiles.</code><code class="descname">loadFromDS</code><span class="sig-paren">(</span><em>filename</em>, <em>filename_y</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygraph/utils/graphfiles.html#loadFromDS"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.graphfiles.loadFromDS" title="Permalink to this definition">¶</a></dt>
  207. <dd><p>Load data from .ds file.
  208. Possible graph formats include:</p>
  209. <blockquote>
  210. <div>‘.ct’: see function loadCT for detail.
  211. ‘.gxl’: see dunction loadGXL for detail.</div></blockquote>
  212. <p>Note these graph formats are checked automatically by the extensions of
  213. graph files.</p>
  214. </dd></dl>
  215. <dl class="function">
  216. <dt id="pygraph.utils.graphfiles.loadFromXML">
  217. <code class="descclassname">pygraph.utils.graphfiles.</code><code class="descname">loadFromXML</code><span class="sig-paren">(</span><em>filename</em>, <em>extra_params</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygraph/utils/graphfiles.html#loadFromXML"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.graphfiles.loadFromXML" title="Permalink to this definition">¶</a></dt>
  218. <dd></dd></dl>
  219. <dl class="function">
  220. <dt id="pygraph.utils.graphfiles.loadGXL">
  221. <code class="descclassname">pygraph.utils.graphfiles.</code><code class="descname">loadGXL</code><span class="sig-paren">(</span><em>filename</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygraph/utils/graphfiles.html#loadGXL"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.graphfiles.loadGXL" title="Permalink to this definition">¶</a></dt>
  222. <dd></dd></dl>
  223. <dl class="function">
  224. <dt id="pygraph.utils.graphfiles.loadMAT">
  225. <code class="descclassname">pygraph.utils.graphfiles.</code><code class="descname">loadMAT</code><span class="sig-paren">(</span><em>filename</em>, <em>extra_params</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygraph/utils/graphfiles.html#loadMAT"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.graphfiles.loadMAT" title="Permalink to this definition">¶</a></dt>
  226. <dd><p>Load graph data from a MATLAB (up to version 7.1) .mat file.</p>
  227. <p>A MAT file contains a struct array containing graphs, and a column vector lx containing a class label for each graph.
  228. Check README in downloadable file in <a class="reference external" href="http://mlcb.is.tuebingen.mpg.de/Mitarbeiter/Nino/WL/">http://mlcb.is.tuebingen.mpg.de/Mitarbeiter/Nino/WL/</a>, 2018 for detailed structure.</p>
  229. </dd></dl>
  230. <dl class="function">
  231. <dt id="pygraph.utils.graphfiles.loadSDF">
  232. <code class="descclassname">pygraph.utils.graphfiles.</code><code class="descname">loadSDF</code><span class="sig-paren">(</span><em>filename</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygraph/utils/graphfiles.html#loadSDF"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.graphfiles.loadSDF" title="Permalink to this definition">¶</a></dt>
  233. <dd><p>load data from structured data file (.sdf file).</p>
  234. <p>A SDF file contains a group of molecules, represented in the similar way as in MOL format.
  235. Check <a class="reference external" href="http://www.nonlinear.com/progenesis/sdf-studio/v0.9/faq/sdf-file-format-guidance.aspx">http://www.nonlinear.com/progenesis/sdf-studio/v0.9/faq/sdf-file-format-guidance.aspx</a>, 2018 for detailed structure.</p>
  236. </dd></dl>
  237. <dl class="function">
  238. <dt id="pygraph.utils.graphfiles.loadTXT">
  239. <code class="descclassname">pygraph.utils.graphfiles.</code><code class="descname">loadTXT</code><span class="sig-paren">(</span><em>dirname_dataset</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygraph/utils/graphfiles.html#loadTXT"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.graphfiles.loadTXT" title="Permalink to this definition">¶</a></dt>
  240. <dd><p>Load graph data from a .txt file.</p>
  241. <p>The graph data is loaded from separate files.
  242. Check README in downloadable file <a class="reference external" href="http://tiny.cc/PK_MLJ_data">http://tiny.cc/PK_MLJ_data</a>, 2018 for detailed structure.</p>
  243. </dd></dl>
  244. <dl class="function">
  245. <dt id="pygraph.utils.graphfiles.saveDataset">
  246. <code class="descclassname">pygraph.utils.graphfiles.</code><code class="descname">saveDataset</code><span class="sig-paren">(</span><em>Gn</em>, <em>y</em>, <em>gformat='gxl'</em>, <em>group=None</em>, <em>filename='gfile'</em>, <em>xparams=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygraph/utils/graphfiles.html#saveDataset"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.graphfiles.saveDataset" title="Permalink to this definition">¶</a></dt>
  247. <dd><p>Save list of graphs.</p>
  248. </dd></dl>
  249. <dl class="function">
  250. <dt id="pygraph.utils.graphfiles.saveGXL">
  251. <code class="descclassname">pygraph.utils.graphfiles.</code><code class="descname">saveGXL</code><span class="sig-paren">(</span><em>graph</em>, <em>filename</em>, <em>method='benoit'</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygraph/utils/graphfiles.html#saveGXL"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.graphfiles.saveGXL" title="Permalink to this definition">¶</a></dt>
  252. <dd></dd></dl>
  253. </div>
  254. <div class="section" id="pygraph-utils-ipython-log-module">
  255. <h2>pygraph.utils.ipython_log module<a class="headerlink" href="#pygraph-utils-ipython-log-module" title="Permalink to this headline">¶</a></h2>
  256. </div>
  257. <div class="section" id="module-pygraph.utils.isNotebook">
  258. <span id="pygraph-utils-isnotebook-module"></span><h2>pygraph.utils.isNotebook module<a class="headerlink" href="#module-pygraph.utils.isNotebook" title="Permalink to this headline">¶</a></h2>
  259. <p>Functions for python system.</p>
  260. <dl class="function">
  261. <dt id="pygraph.utils.isNotebook.isNotebook">
  262. <code class="descclassname">pygraph.utils.isNotebook.</code><code class="descname">isNotebook</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygraph/utils/isNotebook.html#isNotebook"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.isNotebook.isNotebook" title="Permalink to this definition">¶</a></dt>
  263. <dd><p>check if code is executed in the IPython notebook.</p>
  264. </dd></dl>
  265. </div>
  266. <div class="section" id="module-pygraph.utils.kernels">
  267. <span id="pygraph-utils-kernels-module"></span><h2>pygraph.utils.kernels module<a class="headerlink" href="#module-pygraph.utils.kernels" title="Permalink to this headline">¶</a></h2>
  268. <p>Those who are not graph kernels. We can be kernels for nodes or edges!
  269. These kernels are defined between pairs of vectors.</p>
  270. <dl class="function">
  271. <dt id="pygraph.utils.kernels.deltakernel">
  272. <code class="descclassname">pygraph.utils.kernels.</code><code class="descname">deltakernel</code><span class="sig-paren">(</span><em>x</em>, <em>y</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygraph/utils/kernels.html#deltakernel"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.kernels.deltakernel" title="Permalink to this definition">¶</a></dt>
  273. <dd><p>Delta kernel. Return 1 if x == y, 0 otherwise.</p>
  274. <dl class="docutils">
  275. <dt>x, y <span class="classifier-delimiter">:</span> <span class="classifier">any</span></dt>
  276. <dd>Two parts to compare.</dd>
  277. </dl>
  278. <dl class="docutils">
  279. <dt>kernel <span class="classifier-delimiter">:</span> <span class="classifier">integer</span></dt>
  280. <dd>Delta kernel.</dd>
  281. </dl>
  282. <p>[1] H. Kashima, K. Tsuda, and A. Inokuchi. Marginalized kernels between
  283. labeled graphs. In Proceedings of the 20th International Conference on
  284. Machine Learning, Washington, DC, United States, 2003.</p>
  285. </dd></dl>
  286. <dl class="function">
  287. <dt id="pygraph.utils.kernels.gaussiankernel">
  288. <code class="descclassname">pygraph.utils.kernels.</code><code class="descname">gaussiankernel</code><span class="sig-paren">(</span><em>x</em>, <em>y</em>, <em>gamma=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygraph/utils/kernels.html#gaussiankernel"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.kernels.gaussiankernel" title="Permalink to this definition">¶</a></dt>
  289. <dd><p>Gaussian kernel.
  290. Compute the rbf (gaussian) kernel between x and y:</p>
  291. <blockquote>
  292. <div>K(x, y) = exp(-gamma ||x-y||^2).</div></blockquote>
  293. <p>Read more in the <span class="xref std std-ref">User Guide</span>.</p>
  294. <p>x, y : array</p>
  295. <dl class="docutils">
  296. <dt>gamma <span class="classifier-delimiter">:</span> <span class="classifier">float, default None</span></dt>
  297. <dd>If None, defaults to 1.0 / n_features</dd>
  298. </dl>
  299. <p>kernel : float</p>
  300. </dd></dl>
  301. <dl class="function">
  302. <dt id="pygraph.utils.kernels.kernelproduct">
  303. <code class="descclassname">pygraph.utils.kernels.</code><code class="descname">kernelproduct</code><span class="sig-paren">(</span><em>k1</em>, <em>k2</em>, <em>d11</em>, <em>d12</em>, <em>d21=None</em>, <em>d22=None</em>, <em>lamda=1</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygraph/utils/kernels.html#kernelproduct"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.kernels.kernelproduct" title="Permalink to this definition">¶</a></dt>
  304. <dd><p>Product of a pair of kernels.</p>
  305. <p>k = lamda * k1(d11, d12) * k2(d21, d22)</p>
  306. <dl class="docutils">
  307. <dt>k1, k2 <span class="classifier-delimiter">:</span> <span class="classifier">function</span></dt>
  308. <dd>A pair of kernel functions.</dd>
  309. <dt>d11, d12:</dt>
  310. <dd>Inputs of k1. If d21 or d22 is None, apply d11, d12 to both k1 and k2.</dd>
  311. <dt>d21, d22:</dt>
  312. <dd>Inputs of k2.</dd>
  313. <dt>lamda: float</dt>
  314. <dd>Coefficient of the product.</dd>
  315. </dl>
  316. <p>kernel : integer</p>
  317. </dd></dl>
  318. <dl class="function">
  319. <dt id="pygraph.utils.kernels.kernelsum">
  320. <code class="descclassname">pygraph.utils.kernels.</code><code class="descname">kernelsum</code><span class="sig-paren">(</span><em>k1</em>, <em>k2</em>, <em>d11</em>, <em>d12</em>, <em>d21=None</em>, <em>d22=None</em>, <em>lamda1=1</em>, <em>lamda2=1</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygraph/utils/kernels.html#kernelsum"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.kernels.kernelsum" title="Permalink to this definition">¶</a></dt>
  321. <dd><p>Sum of a pair of kernels.</p>
  322. <p>k = lamda1 * k1(d11, d12) + lamda2 * k2(d21, d22)</p>
  323. <dl class="docutils">
  324. <dt>k1, k2 <span class="classifier-delimiter">:</span> <span class="classifier">function</span></dt>
  325. <dd>A pair of kernel functions.</dd>
  326. <dt>d11, d12:</dt>
  327. <dd>Inputs of k1. If d21 or d22 is None, apply d11, d12 to both k1 and k2.</dd>
  328. <dt>d21, d22:</dt>
  329. <dd>Inputs of k2.</dd>
  330. <dt>lamda1, lamda2: float</dt>
  331. <dd>Coefficients of the product.</dd>
  332. </dl>
  333. <p>kernel : integer</p>
  334. </dd></dl>
  335. <dl class="function">
  336. <dt id="pygraph.utils.kernels.linearkernel">
  337. <code class="descclassname">pygraph.utils.kernels.</code><code class="descname">linearkernel</code><span class="sig-paren">(</span><em>x</em>, <em>y</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygraph/utils/kernels.html#linearkernel"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.kernels.linearkernel" title="Permalink to this definition">¶</a></dt>
  338. <dd><p>Polynomial kernel.
  339. Compute the polynomial kernel between x and y:</p>
  340. <blockquote>
  341. <div>K(x, y) = &lt;x, y&gt;.</div></blockquote>
  342. <p>x, y : array</p>
  343. <p>d : integer, default 1</p>
  344. <p>c : float, default 0</p>
  345. <p>kernel : float</p>
  346. </dd></dl>
  347. <dl class="function">
  348. <dt id="pygraph.utils.kernels.polynomialkernel">
  349. <code class="descclassname">pygraph.utils.kernels.</code><code class="descname">polynomialkernel</code><span class="sig-paren">(</span><em>x</em>, <em>y</em>, <em>d=1</em>, <em>c=0</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygraph/utils/kernels.html#polynomialkernel"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.kernels.polynomialkernel" title="Permalink to this definition">¶</a></dt>
  350. <dd><p>Polynomial kernel.
  351. Compute the polynomial kernel between x and y:</p>
  352. <blockquote>
  353. <div>K(x, y) = &lt;x, y&gt; ^d + c.</div></blockquote>
  354. <p>x, y : array</p>
  355. <p>d : integer, default 1</p>
  356. <p>c : float, default 0</p>
  357. <p>kernel : float</p>
  358. </dd></dl>
  359. </div>
  360. <div class="section" id="module-pygraph.utils.logger2file">
  361. <span id="pygraph-utils-logger2file-module"></span><h2>pygraph.utils.logger2file module<a class="headerlink" href="#module-pygraph.utils.logger2file" title="Permalink to this headline">¶</a></h2>
  362. <p>Created on Fri Nov 8 14:21:25 2019</p>
  363. <p>&#64;author: ljia</p>
  364. <dl class="class">
  365. <dt id="pygraph.utils.logger2file.Logger">
  366. <em class="property">class </em><code class="descclassname">pygraph.utils.logger2file.</code><code class="descname">Logger</code><a class="reference internal" href="_modules/pygraph/utils/logger2file.html#Logger"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.logger2file.Logger" title="Permalink to this definition">¶</a></dt>
  367. <dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">object</span></code></p>
  368. <dl class="method">
  369. <dt id="pygraph.utils.logger2file.Logger.flush">
  370. <code class="descname">flush</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygraph/utils/logger2file.html#Logger.flush"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.logger2file.Logger.flush" title="Permalink to this definition">¶</a></dt>
  371. <dd></dd></dl>
  372. <dl class="method">
  373. <dt id="pygraph.utils.logger2file.Logger.write">
  374. <code class="descname">write</code><span class="sig-paren">(</span><em>message</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygraph/utils/logger2file.html#Logger.write"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.logger2file.Logger.write" title="Permalink to this definition">¶</a></dt>
  375. <dd></dd></dl>
  376. </dd></dl>
  377. </div>
  378. <div class="section" id="module-pygraph.utils.model_selection_precomputed">
  379. <span id="pygraph-utils-model-selection-precomputed-module"></span><h2>pygraph.utils.model_selection_precomputed module<a class="headerlink" href="#module-pygraph.utils.model_selection_precomputed" title="Permalink to this headline">¶</a></h2>
  380. <dl class="function">
  381. <dt id="pygraph.utils.model_selection_precomputed.compute_gram_matrices">
  382. <code class="descclassname">pygraph.utils.model_selection_precomputed.</code><code class="descname">compute_gram_matrices</code><span class="sig-paren">(</span><em>dataset</em>, <em>y</em>, <em>estimator</em>, <em>param_list_precomputed</em>, <em>results_dir</em>, <em>ds_name</em>, <em>n_jobs=1</em>, <em>str_fw=''</em>, <em>verbose=True</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygraph/utils/model_selection_precomputed.html#compute_gram_matrices"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.model_selection_precomputed.compute_gram_matrices" title="Permalink to this definition">¶</a></dt>
  383. <dd></dd></dl>
  384. <dl class="function">
  385. <dt id="pygraph.utils.model_selection_precomputed.model_selection_for_precomputed_kernel">
  386. <code class="descclassname">pygraph.utils.model_selection_precomputed.</code><code class="descname">model_selection_for_precomputed_kernel</code><span class="sig-paren">(</span><em>datafile</em>, <em>estimator</em>, <em>param_grid_precomputed</em>, <em>param_grid</em>, <em>model_type</em>, <em>NUM_TRIALS=30</em>, <em>datafile_y=None</em>, <em>extra_params=None</em>, <em>ds_name='ds-unknown'</em>, <em>n_jobs=1</em>, <em>read_gm_from_file=False</em>, <em>verbose=True</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygraph/utils/model_selection_precomputed.html#model_selection_for_precomputed_kernel"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.model_selection_precomputed.model_selection_for_precomputed_kernel" title="Permalink to this definition">¶</a></dt>
  387. <dd><p>Perform model selection, fitting and testing for precomputed kernels
  388. using nested CV. Print out neccessary data during the process then finally
  389. the results.</p>
  390. <dl class="docutils">
  391. <dt>datafile <span class="classifier-delimiter">:</span> <span class="classifier">string</span></dt>
  392. <dd>Path of dataset file.</dd>
  393. <dt>estimator <span class="classifier-delimiter">:</span> <span class="classifier">function</span></dt>
  394. <dd>kernel function used to estimate. This function needs to return a gram matrix.</dd>
  395. <dt>param_grid_precomputed <span class="classifier-delimiter">:</span> <span class="classifier">dictionary</span></dt>
  396. <dd>Dictionary with names (string) of parameters used to calculate gram
  397. matrices as keys and lists of parameter settings to try as values. This
  398. enables searching over any sequence of parameter settings. Params with
  399. length 1 will be omitted.</dd>
  400. <dt>param_grid <span class="classifier-delimiter">:</span> <span class="classifier">dictionary</span></dt>
  401. <dd>Dictionary with names (string) of parameters used as penelties as keys
  402. and lists of parameter settings to try as values. This enables
  403. searching over any sequence of parameter settings. Params with length 1
  404. will be omitted.</dd>
  405. <dt>model_type <span class="classifier-delimiter">:</span> <span class="classifier">string</span></dt>
  406. <dd>Type of the problem, can be ‘regression’ or ‘classification’.</dd>
  407. <dt>NUM_TRIALS <span class="classifier-delimiter">:</span> <span class="classifier">integer</span></dt>
  408. <dd>Number of random trials of outer cv loop. The default is 30.</dd>
  409. <dt>datafile_y <span class="classifier-delimiter">:</span> <span class="classifier">string</span></dt>
  410. <dd>Path of file storing y data. This parameter is optional depending on
  411. the given dataset file.</dd>
  412. <dt>extra_params <span class="classifier-delimiter">:</span> <span class="classifier">dict</span></dt>
  413. <dd>Extra parameters for loading dataset. See function pygraph.utils.
  414. graphfiles.loadDataset for detail.</dd>
  415. <dt>ds_name <span class="classifier-delimiter">:</span> <span class="classifier">string</span></dt>
  416. <dd>Name of the dataset.</dd>
  417. <dt>n_jobs <span class="classifier-delimiter">:</span> <span class="classifier">int</span></dt>
  418. <dd>Number of jobs for parallelization.</dd>
  419. <dt>read_gm_from_file <span class="classifier-delimiter">:</span> <span class="classifier">boolean</span></dt>
  420. <dd>Whether gram matrices are loaded from a file.</dd>
  421. </dl>
  422. <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>&gt;&gt;&gt; import numpy as np
  423. &gt;&gt;&gt; import sys
  424. &gt;&gt;&gt; sys.path.insert(0, &quot;../&quot;)
  425. &gt;&gt;&gt; from pygraph.utils.model_selection_precomputed import model_selection_for_precomputed_kernel
  426. &gt;&gt;&gt; from pygraph.kernels.untilHPathKernel import untilhpathkernel
  427. &gt;&gt;&gt;
  428. &gt;&gt;&gt; datafile = &#39;../datasets/MUTAG/MUTAG_A.txt&#39;
  429. &gt;&gt;&gt; estimator = untilhpathkernel
  430. &gt;&gt;&gt; param_grid_precomputed = {’depth’: np.linspace(1, 10, 10), ’k_func’:
  431. [’MinMax’, ’tanimoto’], ’compute_method’: [’trie’]}
  432. &gt;&gt;&gt; # ’C’ for classification problems and ’alpha’ for regression problems.
  433. &gt;&gt;&gt; param_grid = [{’C’: np.logspace(-10, 10, num=41, base=10)}, {’alpha’:
  434. np.logspace(-10, 10, num=41, base=10)}]
  435. &gt;&gt;&gt;
  436. &gt;&gt;&gt; model_selection_for_precomputed_kernel(datafile, estimator,
  437. param_grid_precomputed, param_grid[0], &#39;classification&#39;, ds_name=’MUTAG’)
  438. </pre></div>
  439. </div>
  440. </dd></dl>
  441. <dl class="function">
  442. <dt id="pygraph.utils.model_selection_precomputed.parallel_trial_do">
  443. <code class="descclassname">pygraph.utils.model_selection_precomputed.</code><code class="descname">parallel_trial_do</code><span class="sig-paren">(</span><em>param_list_pre_revised</em>, <em>param_list</em>, <em>y</em>, <em>model_type</em>, <em>trial</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygraph/utils/model_selection_precomputed.html#parallel_trial_do"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.model_selection_precomputed.parallel_trial_do" title="Permalink to this definition">¶</a></dt>
  444. <dd></dd></dl>
  445. <dl class="function">
  446. <dt id="pygraph.utils.model_selection_precomputed.printResultsInTable">
  447. <code class="descclassname">pygraph.utils.model_selection_precomputed.</code><code class="descname">printResultsInTable</code><span class="sig-paren">(</span><em>param_list</em>, <em>param_list_pre_revised</em>, <em>average_val_scores</em>, <em>std_val_scores</em>, <em>average_perf_scores</em>, <em>std_perf_scores</em>, <em>average_train_scores</em>, <em>std_train_scores</em>, <em>gram_matrix_time</em>, <em>model_type</em>, <em>verbose</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygraph/utils/model_selection_precomputed.html#printResultsInTable"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.model_selection_precomputed.printResultsInTable" title="Permalink to this definition">¶</a></dt>
  448. <dd></dd></dl>
  449. <dl class="function">
  450. <dt id="pygraph.utils.model_selection_precomputed.read_gram_matrices_from_file">
  451. <code class="descclassname">pygraph.utils.model_selection_precomputed.</code><code class="descname">read_gram_matrices_from_file</code><span class="sig-paren">(</span><em>results_dir</em>, <em>ds_name</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygraph/utils/model_selection_precomputed.html#read_gram_matrices_from_file"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.model_selection_precomputed.read_gram_matrices_from_file" title="Permalink to this definition">¶</a></dt>
  452. <dd></dd></dl>
  453. <dl class="function">
  454. <dt id="pygraph.utils.model_selection_precomputed.trial_do">
  455. <code class="descclassname">pygraph.utils.model_selection_precomputed.</code><code class="descname">trial_do</code><span class="sig-paren">(</span><em>param_list_pre_revised</em>, <em>param_list</em>, <em>gram_matrices</em>, <em>y</em>, <em>model_type</em>, <em>trial</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygraph/utils/model_selection_precomputed.html#trial_do"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.model_selection_precomputed.trial_do" title="Permalink to this definition">¶</a></dt>
  456. <dd></dd></dl>
  457. </div>
  458. <div class="section" id="module-pygraph.utils.parallel">
  459. <span id="pygraph-utils-parallel-module"></span><h2>pygraph.utils.parallel module<a class="headerlink" href="#module-pygraph.utils.parallel" title="Permalink to this headline">¶</a></h2>
  460. <p>Created on Tue Dec 11 11:39:46 2018
  461. Parallel aid functions.
  462. &#64;author: ljia</p>
  463. <dl class="function">
  464. <dt id="pygraph.utils.parallel.parallel_gm">
  465. <code class="descclassname">pygraph.utils.parallel.</code><code class="descname">parallel_gm</code><span class="sig-paren">(</span><em>func</em>, <em>Kmatrix</em>, <em>Gn</em>, <em>init_worker=None</em>, <em>glbv=None</em>, <em>method='imap_unordered'</em>, <em>n_jobs=None</em>, <em>chunksize=None</em>, <em>verbose=True</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygraph/utils/parallel.html#parallel_gm"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.parallel.parallel_gm" title="Permalink to this definition">¶</a></dt>
  466. <dd></dd></dl>
  467. <dl class="function">
  468. <dt id="pygraph.utils.parallel.parallel_me">
  469. <code class="descclassname">pygraph.utils.parallel.</code><code class="descname">parallel_me</code><span class="sig-paren">(</span><em>func</em>, <em>func_assign</em>, <em>var_to_assign</em>, <em>itr</em>, <em>len_itr=None</em>, <em>init_worker=None</em>, <em>glbv=None</em>, <em>method=None</em>, <em>n_jobs=None</em>, <em>chunksize=None</em>, <em>itr_desc=''</em>, <em>verbose=True</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygraph/utils/parallel.html#parallel_me"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.parallel.parallel_me" title="Permalink to this definition">¶</a></dt>
  470. <dd></dd></dl>
  471. </div>
  472. <div class="section" id="module-pygraph.utils.trie">
  473. <span id="pygraph-utils-trie-module"></span><h2>pygraph.utils.trie module<a class="headerlink" href="#module-pygraph.utils.trie" title="Permalink to this headline">¶</a></h2>
  474. <p>Created on Wed Jan 30 10:48:49 2019</p>
  475. <p>Trie (prefix tree)
  476. &#64;author: ljia
  477. &#64;references:</p>
  478. <blockquote>
  479. <div><a class="reference external" href="https://viblo.asia/p/nlp-build-a-trie-data-structure-from-scratch-with-python-3P0lPzroKox">https://viblo.asia/p/nlp-build-a-trie-data-structure-from-scratch-with-python-3P0lPzroKox</a>, 2019.1</div></blockquote>
  480. <dl class="class">
  481. <dt id="pygraph.utils.trie.Trie">
  482. <em class="property">class </em><code class="descclassname">pygraph.utils.trie.</code><code class="descname">Trie</code><a class="reference internal" href="_modules/pygraph/utils/trie.html#Trie"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.trie.Trie" title="Permalink to this definition">¶</a></dt>
  483. <dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">object</span></code></p>
  484. <dl class="method">
  485. <dt id="pygraph.utils.trie.Trie.deleteWord">
  486. <code class="descname">deleteWord</code><span class="sig-paren">(</span><em>word</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygraph/utils/trie.html#Trie.deleteWord"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.trie.Trie.deleteWord" title="Permalink to this definition">¶</a></dt>
  487. <dd></dd></dl>
  488. <dl class="method">
  489. <dt id="pygraph.utils.trie.Trie.getNode">
  490. <code class="descname">getNode</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygraph/utils/trie.html#Trie.getNode"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.trie.Trie.getNode" title="Permalink to this definition">¶</a></dt>
  491. <dd></dd></dl>
  492. <dl class="method">
  493. <dt id="pygraph.utils.trie.Trie.insertWord">
  494. <code class="descname">insertWord</code><span class="sig-paren">(</span><em>word</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygraph/utils/trie.html#Trie.insertWord"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.trie.Trie.insertWord" title="Permalink to this definition">¶</a></dt>
  495. <dd></dd></dl>
  496. <dl class="method">
  497. <dt id="pygraph.utils.trie.Trie.load_from_json">
  498. <code class="descname">load_from_json</code><span class="sig-paren">(</span><em>file_name</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygraph/utils/trie.html#Trie.load_from_json"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.trie.Trie.load_from_json" title="Permalink to this definition">¶</a></dt>
  499. <dd></dd></dl>
  500. <dl class="method">
  501. <dt id="pygraph.utils.trie.Trie.load_from_pickle">
  502. <code class="descname">load_from_pickle</code><span class="sig-paren">(</span><em>file_name</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygraph/utils/trie.html#Trie.load_from_pickle"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.trie.Trie.load_from_pickle" title="Permalink to this definition">¶</a></dt>
  503. <dd></dd></dl>
  504. <dl class="method">
  505. <dt id="pygraph.utils.trie.Trie.save_to_json">
  506. <code class="descname">save_to_json</code><span class="sig-paren">(</span><em>file_name</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygraph/utils/trie.html#Trie.save_to_json"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.trie.Trie.save_to_json" title="Permalink to this definition">¶</a></dt>
  507. <dd></dd></dl>
  508. <dl class="method">
  509. <dt id="pygraph.utils.trie.Trie.save_to_pickle">
  510. <code class="descname">save_to_pickle</code><span class="sig-paren">(</span><em>file_name</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygraph/utils/trie.html#Trie.save_to_pickle"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.trie.Trie.save_to_pickle" title="Permalink to this definition">¶</a></dt>
  511. <dd></dd></dl>
  512. <dl class="method">
  513. <dt id="pygraph.utils.trie.Trie.searchWord">
  514. <code class="descname">searchWord</code><span class="sig-paren">(</span><em>word</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygraph/utils/trie.html#Trie.searchWord"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.trie.Trie.searchWord" title="Permalink to this definition">¶</a></dt>
  515. <dd></dd></dl>
  516. <dl class="method">
  517. <dt id="pygraph.utils.trie.Trie.searchWordPrefix">
  518. <code class="descname">searchWordPrefix</code><span class="sig-paren">(</span><em>word</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygraph/utils/trie.html#Trie.searchWordPrefix"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.trie.Trie.searchWordPrefix" title="Permalink to this definition">¶</a></dt>
  519. <dd></dd></dl>
  520. <dl class="method">
  521. <dt id="pygraph.utils.trie.Trie.to_json">
  522. <code class="descname">to_json</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygraph/utils/trie.html#Trie.to_json"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.trie.Trie.to_json" title="Permalink to this definition">¶</a></dt>
  523. <dd></dd></dl>
  524. </dd></dl>
  525. </div>
  526. <div class="section" id="module-pygraph.utils.utils">
  527. <span id="pygraph-utils-utils-module"></span><h2>pygraph.utils.utils module<a class="headerlink" href="#module-pygraph.utils.utils" title="Permalink to this headline">¶</a></h2>
  528. <dl class="function">
  529. <dt id="pygraph.utils.utils.direct_product">
  530. <code class="descclassname">pygraph.utils.utils.</code><code class="descname">direct_product</code><span class="sig-paren">(</span><em>G1</em>, <em>G2</em>, <em>node_label</em>, <em>edge_label</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygraph/utils/utils.html#direct_product"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.utils.direct_product" title="Permalink to this definition">¶</a></dt>
  531. <dd><p>Return the direct/tensor product of directed graphs G1 and G2.</p>
  532. <dl class="docutils">
  533. <dt>G1, G2 <span class="classifier-delimiter">:</span> <span class="classifier">NetworkX graph</span></dt>
  534. <dd>The original graphs.</dd>
  535. <dt>node_label <span class="classifier-delimiter">:</span> <span class="classifier">string</span></dt>
  536. <dd>node attribute used as label. The default node label is ‘atom’.</dd>
  537. <dt>edge_label <span class="classifier-delimiter">:</span> <span class="classifier">string</span></dt>
  538. <dd>edge attribute used as label. The default edge label is ‘bond_type’.</dd>
  539. </dl>
  540. <dl class="docutils">
  541. <dt>gt <span class="classifier-delimiter">:</span> <span class="classifier">NetworkX graph</span></dt>
  542. <dd>The direct product graph of G1 and G2.</dd>
  543. </dl>
  544. <p>This method differs from networkx.tensor_product in that this method only adds nodes and edges in G1 and G2 that have the same labels to the direct product graph.</p>
  545. <p>[1] Thomas Gärtner, Peter Flach, and Stefan Wrobel. On graph kernels: Hardness results and efficient alternatives. Learning Theory and Kernel Machines, pages 129–143, 2003.</p>
  546. </dd></dl>
  547. <dl class="function">
  548. <dt id="pygraph.utils.utils.floydTransformation">
  549. <code class="descclassname">pygraph.utils.utils.</code><code class="descname">floydTransformation</code><span class="sig-paren">(</span><em>G</em>, <em>edge_weight=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygraph/utils/utils.html#floydTransformation"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.utils.floydTransformation" title="Permalink to this definition">¶</a></dt>
  550. <dd><p>Transform graph G to its corresponding shortest-paths graph using Floyd-transformation.</p>
  551. <dl class="docutils">
  552. <dt>G <span class="classifier-delimiter">:</span> <span class="classifier">NetworkX graph</span></dt>
  553. <dd>The graph to be tramsformed.</dd>
  554. <dt>edge_weight <span class="classifier-delimiter">:</span> <span class="classifier">string</span></dt>
  555. <dd>edge attribute corresponding to the edge weight. The default edge weight is bond_type.</dd>
  556. </dl>
  557. <dl class="docutils">
  558. <dt>S <span class="classifier-delimiter">:</span> <span class="classifier">NetworkX graph</span></dt>
  559. <dd>The shortest-paths graph corresponding to G.</dd>
  560. </dl>
  561. <p>[1] Borgwardt KM, Kriegel HP. Shortest-path kernels on graphs. InData Mining, Fifth IEEE International Conference on 2005 Nov 27 (pp. 8-pp). IEEE.</p>
  562. </dd></dl>
  563. <dl class="function">
  564. <dt id="pygraph.utils.utils.getSPGraph">
  565. <code class="descclassname">pygraph.utils.utils.</code><code class="descname">getSPGraph</code><span class="sig-paren">(</span><em>G</em>, <em>edge_weight=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygraph/utils/utils.html#getSPGraph"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.utils.getSPGraph" title="Permalink to this definition">¶</a></dt>
  566. <dd><p>Transform graph G to its corresponding shortest-paths graph.</p>
  567. <dl class="docutils">
  568. <dt>G <span class="classifier-delimiter">:</span> <span class="classifier">NetworkX graph</span></dt>
  569. <dd>The graph to be tramsformed.</dd>
  570. <dt>edge_weight <span class="classifier-delimiter">:</span> <span class="classifier">string</span></dt>
  571. <dd>edge attribute corresponding to the edge weight.</dd>
  572. </dl>
  573. <dl class="docutils">
  574. <dt>S <span class="classifier-delimiter">:</span> <span class="classifier">NetworkX graph</span></dt>
  575. <dd>The shortest-paths graph corresponding to G.</dd>
  576. </dl>
  577. <p>For an input graph G, its corresponding shortest-paths graph S contains the same set of nodes as G, while there exists an edge between all nodes in S which are connected by a walk in G. Every edge in S between two nodes is labeled by the shortest distance between these two nodes.</p>
  578. <p>[1] Borgwardt KM, Kriegel HP. Shortest-path kernels on graphs. InData Mining, Fifth IEEE International Conference on 2005 Nov 27 (pp. 8-pp). IEEE.</p>
  579. </dd></dl>
  580. <dl class="function">
  581. <dt id="pygraph.utils.utils.getSPLengths">
  582. <code class="descclassname">pygraph.utils.utils.</code><code class="descname">getSPLengths</code><span class="sig-paren">(</span><em>G1</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygraph/utils/utils.html#getSPLengths"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.utils.getSPLengths" title="Permalink to this definition">¶</a></dt>
  583. <dd></dd></dl>
  584. <dl class="function">
  585. <dt id="pygraph.utils.utils.get_edge_labels">
  586. <code class="descclassname">pygraph.utils.utils.</code><code class="descname">get_edge_labels</code><span class="sig-paren">(</span><em>Gn</em>, <em>edge_label</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygraph/utils/utils.html#get_edge_labels"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.utils.get_edge_labels" title="Permalink to this definition">¶</a></dt>
  587. <dd><p>Get edge labels of dataset Gn.</p>
  588. </dd></dl>
  589. <dl class="function">
  590. <dt id="pygraph.utils.utils.get_node_labels">
  591. <code class="descclassname">pygraph.utils.utils.</code><code class="descname">get_node_labels</code><span class="sig-paren">(</span><em>Gn</em>, <em>node_label</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygraph/utils/utils.html#get_node_labels"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.utils.get_node_labels" title="Permalink to this definition">¶</a></dt>
  592. <dd><p>Get node labels of dataset Gn.</p>
  593. </dd></dl>
  594. <dl class="function">
  595. <dt id="pygraph.utils.utils.graph_deepcopy">
  596. <code class="descclassname">pygraph.utils.utils.</code><code class="descname">graph_deepcopy</code><span class="sig-paren">(</span><em>G</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygraph/utils/utils.html#graph_deepcopy"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.utils.graph_deepcopy" title="Permalink to this definition">¶</a></dt>
  597. <dd><p>Deep copy a graph, including deep copy of all nodes, edges and
  598. attributes of the graph, nodes and edges.</p>
  599. <p>It is the same as the NetworkX function graph.copy(), as far as I know.</p>
  600. </dd></dl>
  601. <dl class="function">
  602. <dt id="pygraph.utils.utils.graph_isIdentical">
  603. <code class="descclassname">pygraph.utils.utils.</code><code class="descname">graph_isIdentical</code><span class="sig-paren">(</span><em>G1</em>, <em>G2</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygraph/utils/utils.html#graph_isIdentical"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.utils.graph_isIdentical" title="Permalink to this definition">¶</a></dt>
  604. <dd><p>Check if two graphs are identical, including: same nodes, edges, node
  605. labels/attributes, edge labels/attributes.</p>
  606. <ol class="arabic simple">
  607. <li>The type of graphs has to be the same.</li>
  608. <li>Global/Graph attributes are neglected as they may contain names for graphs.</li>
  609. </ol>
  610. </dd></dl>
  611. <dl class="function">
  612. <dt id="pygraph.utils.utils.untotterTransformation">
  613. <code class="descclassname">pygraph.utils.utils.</code><code class="descname">untotterTransformation</code><span class="sig-paren">(</span><em>G</em>, <em>node_label</em>, <em>edge_label</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygraph/utils/utils.html#untotterTransformation"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.utils.untotterTransformation" title="Permalink to this definition">¶</a></dt>
  614. <dd><p>Transform graph G according to Mahé et al.’s work to filter out tottering patterns of marginalized kernel and tree pattern kernel.</p>
  615. <dl class="docutils">
  616. <dt>G <span class="classifier-delimiter">:</span> <span class="classifier">NetworkX graph</span></dt>
  617. <dd>The graph to be tramsformed.</dd>
  618. <dt>node_label <span class="classifier-delimiter">:</span> <span class="classifier">string</span></dt>
  619. <dd>node attribute used as label. The default node label is ‘atom’.</dd>
  620. <dt>edge_label <span class="classifier-delimiter">:</span> <span class="classifier">string</span></dt>
  621. <dd>edge attribute used as label. The default edge label is ‘bond_type’.</dd>
  622. </dl>
  623. <dl class="docutils">
  624. <dt>gt <span class="classifier-delimiter">:</span> <span class="classifier">NetworkX graph</span></dt>
  625. <dd>The transformed graph corresponding to G.</dd>
  626. </dl>
  627. <p>[1] Pierre Mahé, Nobuhisa Ueda, Tatsuya Akutsu, Jean-Luc Perret, and Jean-Philippe Vert. Extensions of marginalized graph kernels. In Proceedings of the twenty-first international conference on Machine learning, page 70. ACM, 2004.</p>
  628. </dd></dl>
  629. </div>
  630. <div class="section" id="module-pygraph.utils">
  631. <span id="module-contents"></span><h2>Module contents<a class="headerlink" href="#module-pygraph.utils" title="Permalink to this headline">¶</a></h2>
  632. <p>Pygraph - utils module</p>
  633. <dl class="docutils">
  634. <dt>Implement some methods to manage graphs</dt>
  635. <dd>graphfiles.py : load .gxl and .ct files
  636. utils.py : compute some properties on networkX graphs</dd>
  637. </dl>
  638. </div>
  639. </div>
  640. </div>
  641. </div>
  642. <footer>
  643. <hr/>
  644. <div role="contentinfo">
  645. <p>
  646. &copy; Copyright 2020, Linlin Jia
  647. </p>
  648. </div>
  649. Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
  650. </footer>
  651. </div>
  652. </div>
  653. </section>
  654. </div>
  655. <script type="text/javascript">
  656. jQuery(function () {
  657. SphinxRtdTheme.Navigation.enable(true);
  658. });
  659. </script>
  660. </body>
  661. </html>

A Python package for graph kernels, graph edit distances and graph pre-image problem.