Hi list, with #6468, it is finally possible to use Graphs from gb.data. You have a base "Graph" class from which all implementations inherit. It also acts like a driver/dispatcher for implementation functions. (Little) more on that below.
GraphMatrix is a concrete graph implementation in gb.data based on an adjacency matrix (a full n*n one at the moment -- I may go for sparse matrices later). More implementations may follow as I have time. You can also create your own graph classes in Gambas. It's more complicated than you might want it to be but you don't invent new graph classes on a daily basis, right? That's mainly because I made excessive use of virtual classes to have a nice interface without additional memory usage. At least the process of creating your own graph class is convoluted enough that I cannot explain it now, so either self-study or wait for the tutorial/ GambasMag article (depends on how fast December approaches) :-) Attached are three projects: - ConnectivityMatrix: shows how to use GraphMatrix. It (sort of) computes the connected components of a graph, but by taking the sum over powers of the adjacency matrix (using gb.gsl). - custom-graph: a very quickly written project which implements a "DirectoryGraph", i.e. a graph which represents a directory hierarchy where "being contained in a directory" and (symbolic) links are edges. The class is written in Gambas and rather minimal. The project creates a (graphviz) dot file and its png of the graph of /usr/lib/gambas3/*so*. - GraphFloodFill: is a more sophisticated project. At its heart it interprets an Image object as a graph by implicitly taking the pixels as vertices and defining edges between pixels of the same colour (or from any colour to white or transparent). The BreadthFirstSearch class implements a BFS for a general Graph object. ImageGraph contains just enough functionality to allow a BFS on it. This together allows to do a flood fill on the backing Image object. There is also a neat little colour chooser because the traditional one from gb.form was too bulky for the form. Questions? Regards, Tobi -- "There's an old saying: Don't change anything... ever!" -- Mr. Monk
ConnectivityMatrix-0.1.1.tar.gz
Description: Binary data
custom-graph-0.0.1.tar.gz
Description: Binary data
GraphFloodfill-0.2.1.tar.gz
Description: Binary data
------------------------------------------------------------------------------ Want excitement? Manually upgrade your production database. When you want reliability, choose Perforce Perforce version control. Predictably reliable. http://pubads.g.doubleclick.net/gampad/clk?id=157508191&iu=/4140/ostg.clktrk
_______________________________________________ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user