Changeset View
Changeset View
Standalone View
Standalone View
java/server/src/main/java/org/softwareheritage/graph/Neighbors.java
package org.softwareheritage.graph; | package org.softwareheritage.graph; | ||||
import java.util.Iterator; | import java.util.Iterator; | ||||
import it.unimi.dsi.big.webgraph.LazyLongIterator; | import it.unimi.dsi.big.webgraph.LazyLongIterator; | ||||
import org.softwareheritage.graph.AllowedEdges; | import org.softwareheritage.graph.AllowedEdges; | ||||
import org.softwareheritage.graph.Graph; | import org.softwareheritage.graph.Graph; | ||||
/** | /** | ||||
* Iterator class to go over a node neighbors in the graph. | * Iterator class to go over a node neighbors in the graph. | ||||
* <p> | * <p> | ||||
* Wrapper iterator class to easily deal with {@link AllowedEdges} during traversals. | * Wrapper iterator class to easily deal with {@link AllowedEdges} during traversals. | ||||
* | * | ||||
* @author Thibault Allançon | * @author Thibault Allançon | ||||
* @version 0.0.1 | |||||
* @since 0.0.1 | |||||
* @see org.softwareheritage.graph.AllowedEdges | * @see org.softwareheritage.graph.AllowedEdges | ||||
*/ | */ | ||||
public class Neighbors implements Iterable<Long> { | public class Neighbors implements Iterable<Long> { | ||||
/** Graph used to explore neighbors */ | /** Graph used to explore neighbors */ | ||||
Graph graph; | Graph graph; | ||||
/** Boolean to specify the use of the transposed graph */ | /** Boolean to specify the use of the transposed graph */ | ||||
boolean useTransposed; | boolean useTransposed; | ||||
Show All 21 Lines | public class Neighbors implements Iterable<Long> { | ||||
public Iterator<Long> iterator() { | public Iterator<Long> iterator() { | ||||
return new NeighborsIterator(); | return new NeighborsIterator(); | ||||
} | } | ||||
/** | /** | ||||
* Inner class for {@link Neighbors} iterator. | * Inner class for {@link Neighbors} iterator. | ||||
* | * | ||||
* @author Thibault Allançon | * @author Thibault Allançon | ||||
* @version 0.0.1 | |||||
* @since 0.0.1 | |||||
*/ | */ | ||||
public class NeighborsIterator implements Iterator<Long> { | public class NeighborsIterator implements Iterator<Long> { | ||||
LazyLongIterator neighbors; | LazyLongIterator neighbors; | ||||
long nextNeighborId; | long nextNeighborId; | ||||
public NeighborsIterator() { | public NeighborsIterator() { | ||||
this.neighbors = graph.neighbors(srcNodeId, useTransposed); | this.neighbors = graph.neighbors(srcNodeId, useTransposed); | ||||
Show All 24 Lines |