public class DefaultALGenerator extends Object implements HGALGenerator, CloseMe
A default implementation of the HGALGenerator
that should cover most
common cases. In the description below, the term focus atom is used to refer
to the atom whose adjacency list is being generated.
The adjacency list generation process is conceptually split into two main steps:
Step 1 may be augmented with a filter to select links only satisfying certain criteria.
This filter is configured in the form of a link predicate, a HGQueryCondition
.
Step 2 may be configured to treat links as ordered. When links are interpreted as ordered, there are several further options:
All of the above mentioned options are configured at construction time. In the simplest case
of no link or sibling filtering and where links are unordered, use the SimpleALGenerator
instead which will be somewhat faster.
Modifier and Type | Class and Description |
---|---|
protected class |
DefaultALGenerator.AdjIterator |
Modifier and Type | Field and Description |
---|---|
protected HyperGraph |
hg |
Constructor and Description |
---|
DefaultALGenerator()
Default constructor available, but the class is not really default constructible -
you must at least specify a
HyperGraph instance on which to operate. |
DefaultALGenerator(HyperGraph graph)
Construct with default values: no link or sibling predicate, returning all
siblings in their normal storage order.
|
DefaultALGenerator(HyperGraph hg,
HGAtomPredicate linkPredicate,
HGAtomPredicate siblingPredicate)
Construct a default adjacency list generator where links are considered unordered.
|
DefaultALGenerator(HyperGraph hg,
HGAtomPredicate linkPredicate,
HGAtomPredicate siblingPredicate,
boolean returnPreceeding,
boolean returnSucceeding,
boolean reverseOrder)
Construct a default adjacency list generator where links are considered ordered.
|
DefaultALGenerator(HyperGraph graph,
HGAtomPredicate linkPredicate,
HGAtomPredicate siblingPredicate,
boolean returnPreceeding,
boolean returnSucceeding,
boolean reverseOrder,
boolean returnSource)
Construct a default adjacency list generator where links are considered ordered.
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
HGSearchResult<Pair<HGHandle,HGHandle>> |
generate(HGHandle h)
Return
HGSearchResult over all atoms adjacent to the passed in
atom. |
HyperGraph |
getGraph() |
HGAtomPredicate |
getLinkPredicate() |
HGAtomPredicate |
getSiblingPredicate() |
boolean |
isReturnPreceeding() |
boolean |
isReturnSource() |
boolean |
isReturnSucceeding() |
boolean |
isReverseOrder() |
DefaultALGenerator |
setGraph(HyperGraph graph) |
DefaultALGenerator |
setLinkPredicate(HGAtomPredicate linkPredicate) |
DefaultALGenerator |
setReturnPreceeding(boolean returnPreceeding) |
DefaultALGenerator |
setReturnSource(boolean returnSource) |
DefaultALGenerator |
setReturnSucceeding(boolean returnSucceeding) |
DefaultALGenerator |
setReverseOrder(boolean reverseOrder) |
DefaultALGenerator |
setSiblingPredicate(HGAtomPredicate siblingPredicate) |
protected HyperGraph hg
public DefaultALGenerator()
Default constructor available, but the class is not really default constructible -
you must at least specify a HyperGraph
instance on which to operate.
public DefaultALGenerator(HyperGraph graph)
Construct with default values: no link or sibling predicate, returning all siblings in their normal storage order.
public DefaultALGenerator(HyperGraph hg, HGAtomPredicate linkPredicate, HGAtomPredicate siblingPredicate)
Construct a default adjacency list generator where links are considered unordered.
hg
- The HyperGraph instance from where incidence sets are fetched.linkPredicate
- The predicate by which links are filtered. Only links satisfying
this predicate will be considered. If this parameter is null
, all links
from the incidence set will be considered.siblingPredicate
- The predicate by which sibling atoms are filtered from the
adjacency list. Only atoms satisfying this predicate will be returned. If this parameter
is null
, all sibling atoms will be considered.public DefaultALGenerator(HyperGraph hg, HGAtomPredicate linkPredicate, HGAtomPredicate siblingPredicate, boolean returnPreceeding, boolean returnSucceeding, boolean reverseOrder)
Construct a default adjacency list generator where links are considered ordered.
The constructor does NOT allow both returnSucceeding
and returnPreceeding
to be set to false
. This will always return empty adjacency lists and does not make
any sense. Even, in a more complex situation where those parameters are determined at run-time
following some unforeseen logic, the caller must make sure that not both of those parameters are
false.
hg
- The HyperGraph instance from where incidence sets are fetched.linkPredicate
- The predicate by which links are filtered. Only links satisfying
this predicate will be considered. If this parameter is null
, all links
from the incidence set will be considered.siblingPredicate
- The predicate by which sibling atoms are filtered from the
adjacency list. Only atoms satisfying this predicate will be returned. If this parameter
is null
, all sibling atoms will be considered.returnPreceeding
- Whether or not to return siblings that appear before the focus
atom in an ordered link.returnSucceding
- Whether or not to return siblings that appear after the focus atom
in an ordered link.reverseOrder
- Whether or not to reverse the default order implied by a link's target
array. Note that this parameter affects the meaning of preceeding and succeeding
in the above two parameters.public DefaultALGenerator(HyperGraph graph, HGAtomPredicate linkPredicate, HGAtomPredicate siblingPredicate, boolean returnPreceeding, boolean returnSucceeding, boolean reverseOrder, boolean returnSource)
Construct a default adjacency list generator where links are considered ordered.
The constructor does NOT allow both returnSucceeding
and returnPreceeding
to be set to false
. This will always return empty adjacency lists and does not make
any sense. Even, in a more complex situation where those parameters are determined at run-time
following some unforeseen logic, the caller must make sure that not both of those parameters are
false.
graph
- The HyperGraph instance from where incidence sets are fetched.linkPredicate
- The predicate by which links are filtered. Only links satisfying
this predicate will be considered. If this parameter is null
, all links
from the incidence set will be considered.siblingPredicate
- The predicate by which sibling atoms are filtered from the
adjacency list. Only atoms satisfying this predicate will be returned. If this parameter
is null
, all sibling atoms will be considered.returnPreceeding
- Whether or not to return siblings that appear before the focus
atom in an ordered link.returnSucceding
- Whether or not to return siblings that appear after the focus atom
in an ordered link.reverseOrder
- Whether or not to reverse the default order implied by a link's target
array. Note that this parameter affects the meaning of preceeding and succeeding
in the above two parameters.returnSource
- Whether to return the source/originating atom along with its siblings. The default
is false.public HGSearchResult<Pair<HGHandle,HGHandle>> generate(HGHandle h)
HGALGenerator
Return HGSearchResult
over all atoms adjacent to the passed in
atom. The result set items are pairs of the form [link, atom] where the first
element is the HGLink
handle of the link that "leads" to the adjacent atom
and the second element is the adjacent atom itself.
generate
in interface HGALGenerator
h
- The handle of the atom of interest.public HyperGraph getGraph()
public DefaultALGenerator setGraph(HyperGraph graph)
public HGAtomPredicate getLinkPredicate()
public DefaultALGenerator setLinkPredicate(HGAtomPredicate linkPredicate)
public HGAtomPredicate getSiblingPredicate()
public DefaultALGenerator setSiblingPredicate(HGAtomPredicate siblingPredicate)
public boolean isReturnPreceeding()
public DefaultALGenerator setReturnPreceeding(boolean returnPreceeding)
public boolean isReturnSucceeding()
public DefaultALGenerator setReturnSucceeding(boolean returnSucceeding)
public boolean isReverseOrder()
public DefaultALGenerator setReverseOrder(boolean reverseOrder)
public boolean isReturnSource()
public DefaultALGenerator setReturnSource(boolean returnSource)
Copyright © 2015. All rights reserved.