01: /*
02: * GeoTools - OpenSource mapping toolkit
03: * http://geotools.org
04: * (C) 2002-2006, GeoTools Project Managment Committee (PMC)
05: * (C) 2002, Refractions Reserach Inc.
06: *
07: * This library is free software; you can redistribute it and/or
08: * modify it under the terms of the GNU Lesser General Public
09: * License as published by the Free Software Foundation;
10: * version 2.1 of the License.
11: *
12: * This library is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15: * Lesser General Public License for more details.
16: */
17: package org.geotools.graph.path;
18:
19: import java.util.Collection;
20: import java.util.HashSet;
21:
22: /**
23: * Represents a path in a graph. A <B>path</B> P is defined as a <B>walk</B>
24: * in which there are no node repetitions.
25: *
26: * @author Justin Deoliveira, Refractions Research Inc, jdeolive@refractions.net
27: *
28: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/extension/graph/src/main/java/org/geotools/graph/path/Path.java $
29: */
30: public class Path extends Walk {
31:
32: public Path() {
33: super ();
34: }
35:
36: //TODO: DOCUMENT ME!
37: public Path(Collection nodes) {
38: super (nodes);
39: }
40:
41: /**
42: * Tests if the path is valid. A valid path satisfies two conditions: <BR>
43: * <BR>
44: * 1. Each pair of adjacent nodes share an edge.<BR>
45: * 2. There are no node repetitions.
46: */
47: public boolean isValid() {
48: if (super .isValid()) {
49: //test repetitions
50: HashSet s = new HashSet(this );
51: return (size() == s.size());
52: }
53:
54: return (false);
55: }
56:
57: }
|