Module fr.univartois.cril.jkahypar
Class AbstractHypergraphBuilder
java.lang.Object
fr.univartois.cril.jkahypar.hypergraph.AbstractHypergraphBuilder
- All Implemented Interfaces:
HypergraphBuilder
The AbstractHypergraphBuilder provides a base implementation for
HypergraphBuilder.- Since:
- 0.2.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected long[]The indices at which the vertices of each hyperedge start inhyperedgeVertices.protected int[]The vertices of the different hyperedges.protected int[]The weights of the hyperedges.protected intThe number of hyperedges in the hypergraph.protected intThe number of vertices in the hypergraph.protected int[]The weights of the vertices. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractHypergraphBuilder(int nbVertices, int nbHyperedges) Creates a new AbstractHypergraphBuilder. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidappendVertex(int vertex) Appends a vertex tohyperedgeVertices.protected voidappendVertices(Hyperedge hyperedge) Appends the vertices of the given hyperedge tohyperedgeVertices.build()Creates the hypergraph built by this builder.long[]Gives the indices at which the vertices of each hyperedge start in the array returned byHypergraphBuilder.getHyperedgeVertices().int[]Gives the vertices of the hyperedges in the hypergraph.intGives the number of hyperedges in the hypergraph.intGives the number of vertices in the hypergraph.protected abstract voidResizes the internal arrays to make sure their lengths correspond exactly to their number of elements.protected abstract voidsetHyperedgeIndex(int index, int vertexIndex) Sets the index at which the vertices of a hyperedge start inhyperedgeIndices.withHyperedge(UnweightedHyperedge hyperedge) Adds anUnweightedHyperedgeto the hypergraph.withHyperedge(WeightedHyperedge hyperedge) Adds aWeightedHyperedgeto the hypergraph.protected abstract HypergraphBuilderwithHyperedgeWeight(int hyperedge, int weight) Sets the weight of a hyperedge in the hypergraph.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface fr.univartois.cril.jkahypar.hypergraph.HypergraphBuilder
withVertexWeight
-
Field Details
-
numberOfVertices
protected int numberOfVerticesThe number of vertices in the hypergraph. -
vertexWeights
protected int[] vertexWeightsThe weights of the vertices. If vertices are not weighted, this array remainsnull. -
numberOfHyperedges
protected int numberOfHyperedgesThe number of hyperedges in the hypergraph. -
hyperedgeWeights
protected int[] hyperedgeWeightsThe weights of the hyperedges. If hyperedges are not weighted, this array remainsnull. -
hyperedgeIndices
protected long[] hyperedgeIndicesThe indices at which the vertices of each hyperedge start inhyperedgeVertices. -
hyperedgeVertices
protected int[] hyperedgeVerticesThe vertices of the different hyperedges.
-
-
Constructor Details
-
AbstractHypergraphBuilder
protected AbstractHypergraphBuilder(int nbVertices, int nbHyperedges) Creates a new AbstractHypergraphBuilder.- Parameters:
nbVertices- The number of vertices in the hypergraph.nbHyperedges- The number of hyperedges in the hypergraph.
-
-
Method Details
-
getNumberOfVertices
public int getNumberOfVertices()Description copied from interface:HypergraphBuilderGives the number of vertices in the hypergraph.- Specified by:
getNumberOfVerticesin interfaceHypergraphBuilder- Returns:
- The number of vertices.
-
getNumberOfHyperedges
public int getNumberOfHyperedges()Description copied from interface:HypergraphBuilderGives the number of hyperedges in the hypergraph.- Specified by:
getNumberOfHyperedgesin interfaceHypergraphBuilder- Returns:
- The number of hyperedges.
-
getHyperedgeIndices
public long[] getHyperedgeIndices()Description copied from interface:HypergraphBuilderGives the indices at which the vertices of each hyperedge start in the array returned byHypergraphBuilder.getHyperedgeVertices().- Specified by:
getHyperedgeIndicesin interfaceHypergraphBuilder- Returns:
- The indices of the vertices for each hyperedge.
- See Also:
-
getHyperedgeVertices
public int[] getHyperedgeVertices()Description copied from interface:HypergraphBuilderGives the vertices of the hyperedges in the hypergraph.- Specified by:
getHyperedgeVerticesin interfaceHypergraphBuilder- Returns:
- The vertices of the different hyperedges.
- See Also:
-
withHyperedge
Description copied from interface:HypergraphBuilderAdds anUnweightedHyperedgeto the hypergraph.- Specified by:
withHyperedgein interfaceHypergraphBuilder- Parameters:
hyperedge- The hyperedge to add.- Returns:
- This builder.
-
withHyperedge
Description copied from interface:HypergraphBuilderAdds aWeightedHyperedgeto the hypergraph.- Specified by:
withHyperedgein interfaceHypergraphBuilder- Parameters:
hyperedge- The hyperedge to add.- Returns:
- This builder.
-
setHyperedgeIndex
protected abstract void setHyperedgeIndex(int index, int vertexIndex) Sets the index at which the vertices of a hyperedge start inhyperedgeIndices.- Parameters:
index- The index of the hyperedge.vertexIndex- The index at which the vertices of the hyperedge start.
-
withHyperedgeWeight
Sets the weight of a hyperedge in the hypergraph.- Parameters:
hyperedge- The hyperedge to set the weight of.weight- The weight of the hyperedge.- Returns:
- This builder.
-
appendVertices
Appends the vertices of the given hyperedge tohyperedgeVertices.- Parameters:
hyperedge- The hyperedge to append the vertices of.
-
appendVertex
protected void appendVertex(int vertex) Appends a vertex tohyperedgeVertices. The size of the array is doubled if there is not enough room to add the vertex.- Parameters:
vertex- The vertex to append.
-
build
Description copied from interface:HypergraphBuilderCreates the hypergraph built by this builder.- Specified by:
buildin interfaceHypergraphBuilder- Returns:
- The built hypergraph.
-
resizeArrays
protected abstract void resizeArrays()Resizes the internal arrays to make sure their lengths correspond exactly to their number of elements.
-