- java.lang.Object
-
- org.arakhne.afc.math.graph.simple.SGraph
-
- All Implemented Interfaces:
Iterable<SGraphSegment>
,Graph<SGraphSegment,SGraphPoint>
public class SGraph extends Object implements Graph<SGraphSegment,SGraphPoint>
This class provides a simple implementation of a graph.- Since:
- 13.0
- Version:
- 17.0 2020-01-04 14:41:42
- Author:
- Stéphane GALLAND
- Maven Group Id:
- org.arakhne.afc.core
- Maven Artifact Id:
- mathgraph
-
-
Constructor Summary
Constructors Constructor Description SGraph()
Construct a simple empty graph.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) void
add(SGraphSegment segment)
Add the given segment.boolean
contains(Object obj)
Replies is this graph contains the given segment.GraphIterator<SGraphSegment,SGraphPoint>
depthIterator(SGraphSegment startingSegment, double depth, double positionFromStartingPoint, SGraphPoint startingPoint, boolean allowManyReplies, boolean assumeOrientedSegments, DynamicDepthUpdater<SGraphSegment,SGraphPoint> dynamicDepthUpdater)
Replies an iterator that permits to move along the segment's graph starting from the specified segment and from the specified starting point.int
getPointCount()
Replies the count of points in this graph.int
getSegmentCount()
Replies the count of segments in this graph.boolean
isEmpty()
Replies if this graph is empty or not.Iterator<SGraphSegment>
iterator()
GraphIterator<SGraphSegment,SGraphPoint>
iterator(SGraphSegment startingSegment, SGraphPoint startingPoint, boolean allowManyReplies, boolean assumeOrientedSegments)
Replies an iterator that permits to move along the road segment's graph starting from this road segment and from the specified starting point.(package private) void
updatePointCount(int amount)
Update the number of points in this graph with the given amount.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.arakhne.afc.math.graph.Graph
depthIterator
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Method Detail
-
iterator
@Pure public Iterator<SGraphSegment> iterator()
- Specified by:
iterator
in interfaceIterable<SGraphSegment>
-
iterator
@Pure public GraphIterator<SGraphSegment,SGraphPoint> iterator(SGraphSegment startingSegment, SGraphPoint startingPoint, boolean allowManyReplies, boolean assumeOrientedSegments)
Description copied from interface:Graph
Replies an iterator that permits to move along the road segment's graph starting from this road segment and from the specified starting point.- Specified by:
iterator
in interfaceGraph<SGraphSegment,SGraphPoint>
- Parameters:
startingSegment
- is the first segment to iterate.startingPoint
- is the starting point of the iterations.allowManyReplies
- may betrue
to allow to reply many times the same segment, otherwhisefalse
.assumeOrientedSegments
- may betrue
to assume that the same segment has two different instances for graph iteration: the first instance is associated the first point of the segment and the second instance is associated to the last point of the segment. If this parameter isfalse
to assume that the end points of a segment are not distinguished.- Returns:
- the iterator.
-
getSegmentCount
@Pure public int getSegmentCount()
Description copied from interface:Graph
Replies the count of segments in this graph.- Specified by:
getSegmentCount
in interfaceGraph<SGraphSegment,SGraphPoint>
- Returns:
- the count of segments in this graph.
-
getPointCount
@Pure public int getPointCount()
Description copied from interface:Graph
Replies the count of points in this graph.- Specified by:
getPointCount
in interfaceGraph<SGraphSegment,SGraphPoint>
- Returns:
- the count of points in this graph.
-
isEmpty
@Pure public boolean isEmpty()
Description copied from interface:Graph
Replies if this graph is empty or not.- Specified by:
isEmpty
in interfaceGraph<SGraphSegment,SGraphPoint>
- Returns:
true
if the graph is empty, otherwisefalse
.
-
contains
@Pure public boolean contains(Object obj)
Description copied from interface:Graph
Replies is this graph contains the given segment. The test is based onObject.equals(Object)
.- Specified by:
contains
in interfaceGraph<SGraphSegment,SGraphPoint>
- Parameters:
obj
- the object to search for.- Returns:
true
if the graph contains the segment, otherwisefalse
.
-
depthIterator
@Pure public GraphIterator<SGraphSegment,SGraphPoint> depthIterator(SGraphSegment startingSegment, double depth, double positionFromStartingPoint, SGraphPoint startingPoint, boolean allowManyReplies, boolean assumeOrientedSegments, DynamicDepthUpdater<SGraphSegment,SGraphPoint> dynamicDepthUpdater)
Description copied from interface:Graph
Replies an iterator that permits to move along the segment's graph starting from the specified segment and from the specified starting point. If the specified starting point is not one of the ends of the segment, this function assumes to start from the point replied byGraphSegment.getBeginPoint()
.This function does not allow the cycles during the iterations.
- Specified by:
depthIterator
in interfaceGraph<SGraphSegment,SGraphPoint>
- Parameters:
startingSegment
- is the first segment to iterate.depth
- is the maximal depth to reach.positionFromStartingPoint
- is the starting position from thestartingPoint
.startingPoint
- is the starting point of the iterations.allowManyReplies
- may betrue
to allow to reply many times the same segment, otherwhisefalse
.assumeOrientedSegments
- may betrue
to assume that the same segment has two different instances for graph iteration: the first instance is associated the first point of the segment and the second instance is associated to the last point of the segment. If this parameter isfalse
to assume that the end points of a segment are not distinguished.dynamicDepthUpdater
- if notnull
, it is a lambda that is used for dynamically updating the maximal depth.- Returns:
- the iterator.
- See Also:
Graph.depthIterator(GraphSegment, double, double, GraphPoint, boolean, boolean)
-
add
void add(SGraphSegment segment)
Add the given segment. The number of points is incremented by 2.- Parameters:
segment
- the segment to add.- Throws:
IllegalStateException
- if the graph is not empty.
-
updatePointCount
void updatePointCount(int amount)
Update the number of points in this graph with the given amount.- Parameters:
amount
- the nbumber of points to add.
-
-