[Qgis-developer] Object owner design in QgsGraphBuilder

Sergey Yakushev yakushevs at gmail.com
Sat Sep 1 13:14:52 PDT 2012


> Documentation blocks added:
> https://github.com/matthias-kuhn/Quantum-GIS/commit/6cae97155901525e93cbdf31af7ac7ad7c103805
>
> Add asserts to protect from accessing null-pointers:
> https://github.com/matthias-kuhn/Quantum-GIS/commit/0b34bd76658688509aef988f37dd8aa755722dbc
>
> Return ids of created vertexes and arcs
> https://github.com/matthias-kuhn/Quantum-GIS/commit/3d4f2251c759bcc1bce91aa1424b79a01c0c22b8

Hello

I do not agree with the addition QgsGraphBuilder return id adding
vertices and edges.

The idea is that QgsGraphDirector clearly specifies identitfier of the
verteces and its coordinates. But, in the current implementation of
QgsGraphBuilder requirement coincides with desire.

Theoretically, you can implement child QgsGraphBuilderInterface that
constructs the object graph without a unique integer identifier. Or,
conversely, it throws coordinate information. But for the analysis of
these objects, you can not use QgsGraphAnalyzer.

In the version of QGIS 1.7 I used AdjacencyMatrix as a graph object:

typedef std :: map <QgsPoint, ArcAttributes, QgsPointCompare>
AdjacencyMatrixString;
typedef std :: map <QgsPoint, AdjacencyMatrixString, QgsPointCompare>
AdjacencyMatrix;

The integer identifier is not applicable to the type AdjacencyMatrix
and maybe in the future someone wants to create a similar object. It
would be unfortunate if QgsGraphDirector childs will depend on the
integer identifier.
For this reason, there is a double Identification of vertices and
edges in QgsGraphDirector and QgsGraphBuilder classes. By integer
identifier and the coordinates of points.

---

Still need to explain the following. If you implement child
QgsGraphDirector, then the correct implementation of the method
makeGraph () should be:

1. Add all the vertices from id = 0 to last.
2. Add all the arc with correct points identifier.

In reverse order reap QgsGraph get bad output.


-- 
Sergey Yakushev

Sorry for a bad english.


More information about the Qgis-developer mailing list