public abstract class Vertex<T> extends java.lang.Object implements Observable<T>, Samplable<T>, HasShape
Modifier and Type | Method and Description |
---|---|
void |
addChild(Vertex<?> v) |
void |
addParent(Vertex<?> parent) |
void |
addParents(java.util.Collection<? extends Vertex> parents) |
boolean |
equals(java.lang.Object o) |
T |
eval()
This causes a backwards propagating calculation of the vertex value.
|
java.util.Set<Vertex> |
getChildren() |
java.util.Set<Vertex> |
getConnectedGraph() |
int |
getDegree() |
VertexId |
getId() |
int |
getIndentation() |
VertexLabel |
getLabel() |
java.util.Optional<T> |
getObservedValue() |
java.util.Set<Vertex> |
getParents() |
protected T |
getRawValue() |
long[] |
getShape() |
T |
getValue() |
int |
hashCode() |
boolean |
hasValue() |
boolean |
isObserved() |
boolean |
isProbabilistic() |
T |
lazyEval()
This is similar to eval() except it only propagates as far up the graph as required until
there are values present to operate on.
|
void |
loadValue(NetworkLoader loader) |
void |
observe(T value)
This marks the vertex's value as being observed and unchangeable.
|
void |
observeOwnValue()
Cause this vertex to observe its own value, for example when generating test data
|
<V extends Vertex<T>> |
removeLabel() |
void |
save(NetworkSaver netSaver) |
void |
saveValue(NetworkSaver netSaver) |
void |
setAndCascade(T value)
This sets the value in this vertex and tells each child vertex about
the new change.
|
<V extends Vertex<T>> |
setLabel(java.lang.String label) |
<V extends Vertex<T>> |
setLabel(VertexLabel label)
Set a label for this vertex.
|
void |
setParents(java.util.Collection<? extends Vertex> parents) |
void |
setParents(Vertex<?>... parents) |
void |
setValue(T value)
Sets the value if the vertex isn't already observed.
|
java.lang.String |
toString() |
void |
unobserve() |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
observableTypeFor
public <V extends Vertex<T>> V setLabel(VertexLabel label)
V
- vertex typelabel
- The label to apply to this vertex. Uniqueness is only enforced on instantiation of a Bayes Netpublic VertexLabel getLabel()
public final T lazyEval()
public final T eval()
public final boolean isProbabilistic()
public void setValue(T value)
value
- the observed valuepublic T getValue()
protected T getRawValue()
public boolean hasValue()
public void setAndCascade(T value)
value
- The new value at this vertexpublic void observe(T value)
Non-probabilistic vertices of continuous types (integer, double) are prohibited from being observed due to its negative impact on inference algorithms. Non-probabilistic booleans are allowed to be observed as well as user defined types.
observe
in interface Observable<T>
value
- the value to be observedpublic void observeOwnValue()
public void unobserve()
unobserve
in interface Observable<T>
public boolean isObserved()
isObserved
in interface Observable<T>
public java.util.Optional<T> getObservedValue()
getObservedValue
in interface Observable<T>
public VertexId getId()
public int getIndentation()
public java.util.Set<Vertex> getChildren()
public void addChild(Vertex<?> v)
public void setParents(java.util.Collection<? extends Vertex> parents)
public void setParents(Vertex<?>... parents)
public void addParents(java.util.Collection<? extends Vertex> parents)
public void addParent(Vertex<?> parent)
public java.util.Set<Vertex> getParents()
public int getDegree()
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.util.Set<Vertex> getConnectedGraph()
public java.lang.String toString()
toString
in class java.lang.Object
public void save(NetworkSaver netSaver)
public void saveValue(NetworkSaver netSaver)
public void loadValue(NetworkLoader loader)