public class SSSP extends BaseGASProgram<SSSP.VS,SSSP.ES,Integer> implements IPredecessor<SSSP.VS,SSSP.ES,Integer>
Modifier and Type | Class and Description |
---|---|
static interface |
SSSP.Bindings
Additional
IBindingExtractor.IBinder s exposed by SSSP . |
static class |
SSSP.ES
Edge state is not used.
|
static class |
SSSP.VS |
Constructor and Description |
---|
SSSP() |
Modifier and Type | Method and Description |
---|---|
SSSP.VS |
apply(IGASState<SSSP.VS,SSSP.ES,Integer> state,
org.openrdf.model.Value u,
Integer sum)
NOP.
|
Integer |
gather(IGASState<SSSP.VS,SSSP.ES,Integer> state,
org.openrdf.model.Value u,
org.openrdf.model.Statement e)
src.dist + edge_length (1) |
List<IBinder<SSSP.VS,SSSP.ES,Integer>> |
getBinderList()
Return a list of interfaces that may be used to extract variable bindings
for the vertices visited by the algorithm.
|
EdgesEnum |
getGatherEdges()
Return the set of edges to which the GATHER is applied for a
directed graph -or-
EdgesEnum.NoEdges to skip the GATHER
phase. |
FrontierEnum |
getInitialFrontierEnum()
Return the nature of the initial frontier for this algorithm.
|
EdgesEnum |
getScatterEdges()
Return the set of edges to which the SCATTER is applied for a
directed graph -or-
EdgesEnum.NoEdges to skip the
SCATTER phase. |
Factory<org.openrdf.model.Value,SSSP.VS> |
getVertexStateFactory()
Return a factory for vertex state objects.
|
void |
initVertex(IGASContext<SSSP.VS,SSSP.ES,Integer> ctx,
IGASState<SSSP.VS,SSSP.ES,Integer> state,
org.openrdf.model.Value u)
Set the
SSSP.VS.dist() to ZERO (0). |
boolean |
nextRound(IGASContext<SSSP.VS,SSSP.ES,Integer> ctx)
Return
true iff the algorithm should continue. |
void |
prunePaths(IGASContext<SSSP.VS,SSSP.ES,Integer> ctx,
org.openrdf.model.Value[] targetVertices)
Remove any vertices from the visited set that do not line on path that
leads to at least one of the target vertices.
|
void |
scatter(IGASState<SSSP.VS,SSSP.ES,Integer> state,
IGASScheduler sch,
org.openrdf.model.Value u,
org.openrdf.model.Statement e)
The remote vertex is scheduled the weighted edge from this vertex to the
remote vertex plus the weight on this vertex is less than the weight on
the remote vertex.
|
Integer |
sum(IGASState<SSSP.VS,SSSP.ES,Integer> state,
Integer left,
Integer right)
UNUSED.
|
before, getEdgeStateFactory, getSampleEdgesFilter, isChanged
public Factory<org.openrdf.model.Value,SSSP.VS> getVertexStateFactory()
IGASOptions
Note: A null
value may not be allowed in the visited vertex
map, so if the algorithm does not use vertex state, then the factory
should return a singleton instance each time it is invoked.
getVertexStateFactory
in interface IGASOptions<SSSP.VS,SSSP.ES,Integer>
public FrontierEnum getInitialFrontierEnum()
IGASOptions
getInitialFrontierEnum
in interface IGASOptions<SSSP.VS,SSSP.ES,Integer>
public EdgesEnum getGatherEdges()
BaseGASProgram
EdgesEnum.NoEdges
to skip the GATHER
phase. This will be interpreted based on the value reported by
IGASContext#isDirectedTraversal()
.
TODO We may need to set dynamically when visting the vertex in the
frontier rather than having it be a one-time property of the vertex
program.
The default gathers on the EdgesEnum.InEdges
.
getGatherEdges
in interface IGASOptions<SSSP.VS,SSSP.ES,Integer>
getGatherEdges
in class BaseGASProgram<SSSP.VS,SSSP.ES,Integer>
public EdgesEnum getScatterEdges()
BaseGASProgram
EdgesEnum.NoEdges
to skip the
SCATTER phase. This will be interpreted based on the value reported by
IGASContext#isDirectedTraversal()
.
The default scatters on the EdgesEnum.OutEdges
.
getScatterEdges
in interface IGASOptions<SSSP.VS,SSSP.ES,Integer>
getScatterEdges
in class BaseGASProgram<SSSP.VS,SSSP.ES,Integer>
public void initVertex(IGASContext<SSSP.VS,SSSP.ES,Integer> ctx, IGASState<SSSP.VS,SSSP.ES,Integer> state, org.openrdf.model.Value u)
SSSP.VS.dist()
to ZERO (0).
Callback to initialize the state for each vertex in the initial frontier before the first iteration. A typical use case is to set the distance of the starting vertex to ZERO (0).
The default is a NOP.
initVertex
in interface IGASProgram<SSSP.VS,SSSP.ES,Integer>
initVertex
in class BaseGASProgram<SSSP.VS,SSSP.ES,Integer>
u
- The vertex.
TODO We do not need both the IGASContext
and the
IGASState
. The latter is available from the former.public Integer gather(IGASState<SSSP.VS,SSSP.ES,Integer> state, org.openrdf.model.Value u, org.openrdf.model.Statement e)
src.dist + edge_length (1)
GATHER is a map/reduce over the edges of the vertex. The SUM provides pair-wise reduction over the edges visited by the GATHER.
gather
in interface IGASProgram<SSSP.VS,SSSP.ES,Integer>
u
- The vertex for which the gather is being performed. The gather
will be invoked for each edge indident on u
(as
specified by IGASOptions.getGatherEdges()
).e
- An edge (s,p,o).Note: by lazily resolving the vertex and/or edge state in the GAS callback methods we avoid eagerly materializing data that we do not need. [Lazy resolution does not work on a cluster. The only available semantics there are lazy resolution of state that was materialized in order to support a gather() or scatter() for a vertex.]
Note: The state associated with the source/target vertex and the edge should all be immutable for the GATHER. The vertex state should only be mutable for the APPLY(). The target vertex state and/or edge state MAY be mutable for the SCATTER, but that depends on the algorithm. How can we get these constraints into the API?
public Integer sum(IGASState<SSSP.VS,SSSP.ES,Integer> state, Integer left, Integer right)
sum
in interface IGASProgram<SSSP.VS,SSSP.ES,Integer>
left
- An edge state accumulant.right
- Another edge state accumulant.Value
implementation of the backend. E.g., Value versus IV.public SSSP.VS apply(IGASState<SSSP.VS,SSSP.ES,Integer> state, org.openrdf.model.Value u, Integer sum)
apply
in interface IGASProgram<SSSP.VS,SSSP.ES,Integer>
u
- The vertex.sum
- The aggregated accumulate across the edges as computed by
GATHER and SUM -or- null
if there is no
accumulant (this will happen if the GATHER did not find any
edges to visit).public void scatter(IGASState<SSSP.VS,SSSP.ES,Integer> state, IGASScheduler sch, org.openrdf.model.Value u, org.openrdf.model.Statement e)
scatter
in interface IGASProgram<SSSP.VS,SSSP.ES,Integer>
u
- The vertex for which the scatter will being performed.e
- The edge.public boolean nextRound(IGASContext<SSSP.VS,SSSP.ES,Integer> ctx)
BaseGASProgram
true
iff the algorithm should continue. This is
invoked after every iteration, once the new frontier has been computed
and IGASState.round()
has been advanced. An implementation may
simply return true
, in which case the algorithm will
continue IFF the current frontier is not empty.
Note: While this can be used to make custom decisions concerning the
halting criteria, it can also be used as an opportunity to handshake with
a custom IGraphAccessor
in order to process a dynamic graph.
The default returns true
.
nextRound
in interface IGASProgram<SSSP.VS,SSSP.ES,Integer>
nextRound
in class BaseGASProgram<SSSP.VS,SSSP.ES,Integer>
ctx
- The evaluation context.true
if the algorithm should continue (as long as
the frontier is non-empty).public List<IBinder<SSSP.VS,SSSP.ES,Integer>> getBinderList()
getBinderList
in interface IBindingExtractor<SSSP.VS,SSSP.ES,Integer>
getBinderList
in class BaseGASProgram<SSSP.VS,SSSP.ES,Integer>
public void prunePaths(IGASContext<SSSP.VS,SSSP.ES,Integer> ctx, org.openrdf.model.Value[] targetVertices)
IPredecessor
prunePaths
in interface IPredecessor<SSSP.VS,SSSP.ES,Integer>
ctx
- The IGASContext
.targetVertices
- An array of zero or more target vertices.Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.