PageRenderTime 41ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/ComputerAlgebra/Graphs/Lisp/plans/general.hpp

https://github.com/exp04shy/oklibrary
C++ Header | 302 lines | 0 code | 2 blank | 300 comment | 0 complexity | da7155387fdd9dbbfd41c221297cfc26 MD5 | raw file
  1. // Oliver Kullmann, 24.11.2007 (Swansea)
  2. /* Copyright 2007, 2008, 2009, 2010, 2011 Oliver Kullmann
  3. This file is part of the OKlibrary. OKlibrary is free software; you can redistribute
  4. it and/or modify it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation and included in this library; either version 3 of the
  6. License, or any later version. */
  7. /*!
  8. \file ComputerAlgebra/Graphs/Lisp/plans/general.hpp
  9. \brief Plans for graphs in Maxima/Lisp
  10. \todo Organisation
  11. <ul>
  12. <li> See module "GraphTraversal" below. </li>
  13. <li> See module "Treewidth" below. </li>
  14. <li> See module "Matchings" below. </li>
  15. <li> See module "Drawings" below. </li>
  16. <li> Likely we should have modules "Homomorphisms" and "Isomorphisms".
  17. <ol>
  18. <li> It seems yet we have nothing on graph homo/isomorphisms. </li>
  19. <li> Though isomorphisms are special homomorphisms, it seems their
  20. treatment is so specialised that we should have two independent
  21. modules. </li>
  22. <li> There are also categories of graphs: Likely the organisation here
  23. should be the same as for hypergraphs and for clause-sets. </li>
  24. <li> In ComputerAlgebra/Satisfiability we have "Symmetries" instead of
  25. "Isomorphisms", and we have "Categories" which includes "Homomorphisms".
  26. </li>
  27. <li> So perhaps also here we should have modules "Symmetries" and
  28. "Categories". </li>
  29. </ol>
  30. </li>
  31. <li> We need a submodule "Colourings". </li>
  32. <li> A submodule "IndependentSets". </li>
  33. <li> A submodule "Cliques". </li>
  34. <li> Likely also a submodule "RandomGraphs". </li>
  35. <li> And a submodule "RamseyTheory" (but this perhaps better belongs
  36. to Hypergraphs ?). </li>
  37. <li> DONE See module "Trees" below. </li>
  38. </ul>
  39. \todo Complete tests
  40. <ul>
  41. <li> ComputerAlgebra/Graphs/Lisp/Basic.mac
  42. <ol>
  43. <li> Checking the defining properties : DONE</li>
  44. <li> Checking equality : DONE </li>
  45. <li> Promotions : DONE </li>
  46. <li> Downcasts : DONE </li>
  47. <li> Conversions : DONE </li>
  48. <li> Basic graph operations : DONE </li>
  49. <li> Basic graph constructions : DONE </li>
  50. <li> Tests </li>
  51. <li> Connections to Maxima-graphs </li>
  52. </ol>
  53. </li>
  54. <li> Once all these tests are completed, new functions are only
  55. to be entered with tests. </li>
  56. </ul>
  57. \todo Redesign
  58. <ul>
  59. <li> See "Plan the redesign" in ComputerAlgebra/plans/Maxima.hpp for
  60. the general overview. </li>
  61. <li> See "Lists instead of sets" and "Naming conventions" below. </li>
  62. </ul>
  63. \todo Representing edge and vertex labellings
  64. <ul>
  65. <li> One needs to be able to represent an edge, or vertex labelling of a
  66. given graph in the maxima system. </li>
  67. <li> It should then be possible to visualise this somehow using some graph
  68. drawing package, or produce LaTeX output to draw the graph with the
  69. appropriate labels or colours. </li>
  70. <li> See '"Visualising" solutions' in
  71. Experimentation/Investigations/RamseyTheory/RamseyProblems/plans/general.hpp
  72. for potential use in visualising counter examples for Ramsey number SAT
  73. problems. </li>
  74. <li> See also "Representing edge and vertex labellings" in
  75. ComputerAlgebra/Hypergraphs/Lisp/plans/general.hpp . </li>
  76. </ul>
  77. \todo Lists instead of sets
  78. <ul>
  79. <li> Additionally to "graphs" and "general graphs" we introduce
  80. "ordered graphs" and "ordered general graphs":
  81. <ol>
  82. <li> Computationally these notions are considered to be more fundamental.
  83. </li>
  84. <li> An ordered graphs is a pair [V,E], where V and E are lists
  85. without repetition, such that [setify(V),setify(E)] is a graph. </li>
  86. <li> An ordered general graph is a triple [V,E,f], where V, E
  87. are lists without repetition, such that [setify(V),setify(E)] is a
  88. general graph. </li>
  89. <li> An ordered multigraph is a triple [V,E,f], where [V,E] is an
  90. ordered graph, such that for the underlying graph [V',E'] it is
  91. [V',E,',f] a multigraph. </li>
  92. </ol>
  93. </li>
  94. </ul>
  95. \todo Graphs as hypergraphs
  96. <ul>
  97. <li> The topic is discussed in "Polar hypergraphs" in
  98. ComputerAlgebra/Hypergraphs/Lisp/plans/Basics.hpp. </li>
  99. <li> We need a good overview on the different representations of graphs
  100. via hypergraphs, incidence structures and combinatorial matrices:
  101. <ol>
  102. <li> On the one hand, these representations show different points of
  103. view. </li>
  104. <li> And on the other hand they provide different data structures! </li>
  105. </ol>
  106. </li>
  107. </ul>
  108. \todo Memoisation for general graphs and multigraphs
  109. <ul>
  110. <li> The function f in a general graph [V,E,f] could show three different
  111. types of computational strategies for computing f(e):
  112. <ol>
  113. <li> (i) f(e) could always be computed from scratch. </li>
  114. <li> (ii) The other extreme is to store f as an array (and thus only
  115. compute the values once, when creating the general graph). </li>
  116. <li> (iii) The intermediate strategy is the "lazy" one, where f(e) is
  117. computed only when needed, and then stored; see "Memoisation" in
  118. ComputerAlgebra/CombinatorialMatrices/Lisp/plans/general.hpp for how
  119. to do this. </li>
  120. <li> It seems that in many cases the first strategy is alright, since
  121. different from combinatorial matrices, the edges in general graphs
  122. typically are just simple naming-issues. </li>
  123. <li> Also for multigraphs, in the typical applications the multiplicity
  124. of an edge is typically "given", not computed. </li>
  125. <li> However for example for conflict-graphs of clause-sets it seems best
  126. to compute f up-front (using (ii)). </li>
  127. <li> Using a hash-map inside f is made easy by lambda_hm; though, since
  128. E is fixed, an array would be more efficient but this works only
  129. for edge-labels which are consecutive integers. </li>
  130. </ol>
  131. </li>
  132. </ul>
  133. \todo Maxima package "graphs"
  134. <ul>
  135. <li> DONE (solved with version 5.18.1)
  136. Problems with the graph without vertices:
  137. <ol>
  138. <li>
  139. \verbatim
  140. is_bipartite(empty_graph(0));
  141. Evaluation took 0.0040 seconds (0.0001 elapsed) using 1.148 KB.
  142. (%o294) false
  143. \endverbatim
  144. though it should be true. </li>
  145. <li> We also have
  146. \verbatim
  147. complete_graph(0);
  148. Argument 1 to complete_graph is not a positive integer
  149. -- an error. To debug this try debugmode(true);
  150. \endverbatim
  151. </li>
  152. </ol>
  153. </li>
  154. <li> What is petersen_graph(n,d)?
  155. <ol>
  156. <li> We always have the outer and the inner cirle (each of
  157. length n), with the direct connections, and d is then the "step" to
  158. the next vertex on the inner circle. </li>
  159. <li> Thus for d=0 there is no edge, for d=1 we have the two parallel
  160. edges, for n=2 we skip one (as for the Petersen graph), and for d=n/2
  161. we get parallel edges. </li>
  162. <li> The parallel edges shouldn't be possible? </li>
  163. <li> And for d=0 actually print_graph shows loops?? </li>
  164. <li> Tell the mailing-list, that this needs documentation, and that
  165. the non-graph cases needs investigation. </li>
  166. </ol>
  167. </li>
  168. <li> In general we need to write docus for all the undocumented notions
  169. w.r.t. the Maxima graphs-module. </li>
  170. <li> We need conversions between graphs and maxima-graphs.
  171. <ol>
  172. <li> We can use the vertex-labels (assuming they are present). </li>
  173. <li> Currently, mg2g doesn't use the vertex labels (since they might not
  174. be there). </li>
  175. <li> So we need a second version, which also translates the vertex labels.
  176. </li>
  177. <li> How to call it? Which version is standard? Perhaps mg2g should
  178. translate the vertex labels, and "mg2g_nl" doesn't translate them.
  179. </li>
  180. <li> DONE (no loops possible; so we have only "graphs" and "directed graphs")
  181. What about loops? Are they possible with Maxima graphs? </li>
  182. </ol>
  183. </li>
  184. <li> We need conversions between directed graphs and maxima-digraphs.
  185. <ol>
  186. <li> "dg2mdg" needs to be complemented by two inverses, mdg2dg and
  187. mdg2dg_nvl. </li>
  188. <li> DONE (not possible)
  189. What about loops? </li>
  190. </ol>
  191. </li>
  192. <li> DONE (the vertex names become vertex labels)
  193. Given a graph, we can either just forget the vertex names, or use
  194. them as vertex labels. </li>
  195. <li> DONE And given a maxima-graph, we can use the standard-vertex-names
  196. 0, ... </li>
  197. <li> DONE (only "graphs" and "digraphs", nothing else)
  198. Do Maxima graphs allow parallel edges? Apparently not. </li>
  199. <li> DONE (exact values are computed)
  200. We need to find out whether for example the colouring function computes an
  201. exact value or an approximation! See my e-mail to the maxima-mailing-list. </li>
  202. <li> DONE (solved with installed gnuplot-version)
  203. Bug (with 5.14.0 and 5.15.0):
  204. \verbatim
  205. draw_graph(complete_graph(3))$
  206. gnuplot> plot '/home/kullmann/data.gnuplot' index 0 t '' w lp ps 1 pt 0 lw 1 lt 1 lc rgb 'black', '/home/kullmann/data.gnuplot' index 1 t '' w lp ps 1 pt 0 lw 1 lt 1 lc rgb 'black', '/home/kullmann/data.gnuplot' index 2 t '' w lp ps 1 pt 0 lw 1 lt 1 lc rgb 'black', '/home/kullmann/data.gnuplot' index 3 t '' w p ps 2 pt 7 lc rgb 'red'
  207. "/home/kullmann/maxout.gnuplot", line 22: ';' expected
  208. \endverbatim
  209. Notify maxima mailing-list. </li>
  210. </ul>
  211. \todo Graph traversal
  212. <ul>
  213. <li> This likely deserves its own module "GraphTraversal". </li>
  214. <li> Implement the generic graph traversal from module CS-232. </li>
  215. <li> This is likely best done with the maxima-graphs. </li>
  216. <li> Compute connected components and strong connected components. </li>
  217. </ul>
  218. \todo Treewidth
  219. <ul>
  220. <li> Implement all basic methods for computing the treewidth of a graph. </li>
  221. <li> See Combinatorics/Graphs/TreeDecompositions/EliminationSequences.hpp for
  222. one algorithm, and
  223. Combinatorics/Graphs/TreeDecompositions/plans/EliminationSequences.hpp for
  224. plans. </li>
  225. <li> See also Combinatorics/Graphs/TreeDecompositions/plans/general.hpp.
  226. </li>
  227. </ul>
  228. \todo Primitive directed graphs etc.
  229. <ul>
  230. <li> Compute the index of imprimitivity of a directed graph (with loops).
  231. </li>
  232. <li> And for primitive directed graphs (with loops) compute the index of
  233. primitivity. </li>
  234. <li> Again, perhaps best done with the maxima-graph-package. But then loops
  235. need to be handled specially (is this reasonable?). </li>
  236. </ul>
  237. \todo Generalised matching problems
  238. <ul>
  239. <li> Implement [David G. Kirkpatrick and Pavol Hell, On the completeness of
  240. a generalized matching problem, STOC'78]. </li>
  241. <li> That is, the NP-completeness results (as reductions), and the polytime
  242. algorithms. </li>
  243. <li> Perhaps this has been extended, and perhaps also simplified? </li>
  244. <li> A variant is considered in [Dorit Dor and Michael Tarsi, Graph
  245. Decomposition is NP-Complete: A Complete Proof of Holyer's Conjecture,
  246. SIAM Journal on Computing, 1997]. </li>
  247. </ul>
  248. \todo Graph drawing
  249. <ul>
  250. <li> This should become module "Drawings". </li>
  251. <li> We need our own graph-drawing functions:
  252. <ol>
  253. <li> Maxima cannot handle loops nor parallel edges. </li>
  254. <li> The drawing algorithms are rather weak (but we should also try
  255. the possible plug-ins). </li>
  256. <li> We need reference-algorithms. </li>
  257. <li> And we need the possibility to fix our own drawings (for an example
  258. see "Visualising automorphisms" in
  259. ComputerAlgebra/Graphs/Lisp/Isomorphisms/plans/Homomorphisms.hpp). </li>
  260. </ol>
  261. </li>
  262. <li> We need to find out to what extend the Gnuplot functions can be used
  263. (this is likely our own possibility anyway). </li>
  264. <li> But we must establish an abstract level, where the algorithms
  265. only produce abstract tree-drawings (just usual Maximal-lists, with
  266. coordinates and other information), and as a separate layer then these
  267. abstractions are drawn. </li>
  268. <li> Does there exist some basic "vocabulary" ? </li>
  269. <li> Likely other graph-drawing packages can read such drawings (in a
  270. suitable output, of course). See "Concepts" in
  271. GraphDrawing/plans/general.hpp. </li>
  272. </ul>
  273. */