public TypeList GetIncomingEdgesFromGateNode(long gateNode) { // Empty TypeList: Add edges later TypeList edges = new TypeList(); // Get ALL edge types TypeList allEdgesList = g.FindEdgeTypes(); using (TypeListIterator allEdgesIterator = allEdgesList.Iterator()) { // Iterate over ALL edge types while (allEdgesIterator.HasNext()) { // Get edge type int nextEdge = allEdgesIterator.Next(); // Any neighbors? Objects neighbors = g.Neighbors(gateNode, nextEdge, EdgesDirection.Ingoing); // If neighbors exist if (neighbors.Count() > 0) { // Add edge to edges TypeList edges.Add(nextEdge); } // Get rid of neighbors neighbors.Close(); neighbors.Dispose(); } } // Done with allEdgesList allEdgesList.Dispose(); return edges; }
public TypeList GetIncomingEdgesFromGateNode(long gateNode)
{
// Empty TypeList: Add edge TYPES later
TypeList edgeTypes = new TypeList();
// Get ALL edge types
TypeList allEdgeTypesList = g.FindEdgeTypes();
// Empty Objecs: All the incoming edges (not types)
// Not needed if you really only want the edge types
Objects edges = session.NewObjects();
using (TypeListIterator allEdgeTypesList = allEdgeTypesList.Iterator())
{
// Iterate over ALL edges
while (allEdgeTypesList.HasNext())
{
// Get edge TYPE ID
int nextEdgeType = allEdgeTypesList.Next();
// Get the incoming edges of this type
Objects nextEdges = g.Explode(gateNode, nextEdgeType, EdgesDirection.Ingoing);
// If incoming edges exist
if (nextEdges.Count() > 0)
{
// Add edge TYPE to edges TypeList
edgeTypes.Add(nextEdgeType)
// Keep all the edges
edges.Union(nextEdges); // only if you want to find the edges, not only the types
}
// Get rid of nextEdges
nextEdges.Close();
}
}
// Done with allEdgeTypesList
allEdgeTypesList.Dispose();
// Return the types of the incoming edges (edgeTypes)
// Or return the incoming edges (edges)
edges.Close(); // If you only want the edge TYPES, the edges Objects was not really needed
return edgeTypes;
}