Hi,
    That is interesting, i think using your code example would mean that
only the start node and end node of line abcd would overlap with the start
point of line ac, therefore giving three nodes when the graph is built, but
I am not 100% on that. If I am right then the example below should also work
and return 4 nodes  :-

GeometryFactory geometryFactory = JTSFactoryFinder.getGeometryFactory(null); 
LineStringGraphGenerator lineStringGen = new LineStringGraphGenerator(); 

Point a = geometryFactory.createPoint(new Coordinate(0, 0)); 
Point b = geometryFactory.createPoint(new Coordinate(1, 0)); 
Point c = geometryFactory.createPoint(new Coordinate(1, 1)); 
Point d = geometryFactory.createPoint(new Coordinate(0, 1)); 

LineString abc = geometryFactory.createLineString(new Coordinate[] { 
                new Coordinate(a.getX(), a.getY()), new Coordinate(b.getX(),
b.getY()), 
                new Coordinate(c.getX(), c.getY()) }); 

LineString adc = geometryFactory.createLineString(new Coordinate[] { 
                new Coordinate(a.getX(), a.getY()), new Coordinate(d.getX(),
d.getY()), 
                new Coordinate(c.getX(), c.getY()) }); 

LineString ac = geometryFactory.createLineString(new Coordinate[] { 
                new Coordinate(a.getX(), a.getY()), new Coordinate(c.getX(),
c.getY()) }); 

lineStringGen.add(abc);
lineStringGen.add(adc); 
lineStringGen.add(ac); 
Graph g = lineStringGen.getGraph(); 

Additionally, from personal experience when you start applying the Graph
library to real network datasets the fun really begins.... :-)

Kind Regards,

Paul.

--
View this message in context: 
http://osgeo-org.1803224.n2.nabble.com/problem-with-building-graph-tp6386745p6394466.html
Sent from the geotools-gt2-users mailing list archive at Nabble.com.

------------------------------------------------------------------------------
What Every C/C++ and Fortran developer Should Know!
Read this article and learn how Intel has extended the reach of its 
next-generation tools to help Windows* and Linux* C/C++ and Fortran 
developers boost performance applications - including clusters. 
http://p.sf.net/sfu/intel-dev2devmay
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to