Get the neighbors of a given node.
The category graph is treated as an undirected graph.
@param node the reference node.
@return The set of category nodes that are neighbors of this category.
777360
protected Set<Integer> getNeighbors(int node) {

        Set<Integer> neighbors = new HashSet<Integer>();
        Set<DefaultEdge> edges = undirectedGraph.edgesOf(node);
        for (DefaultEdge edge : edges) {
            if (undirectedGraph.getEdgeSource(edge) != node) {
                neighbors.add(undirectedGraph.getEdgeSource(edge));
            }
            if (undirectedGraph.getEdgeTarget(edge) != node) {
                neighbors.add(undirectedGraph.getEdgeTarget(edge));
            }
        }
        return neighbors;
    }
887929
public IntArrayList bfs(int root, boolean isRootT1, boolean[] marked1, boolean[] marked2) {
        IntArrayList ccorder = new IntArrayList();
        Queue<Integer> qNode = new ArrayDeque<>();
        Queue<Boolean> qIsT1 = new ArrayDeque<>();
        qNode.add(root);
        qIsT1.add(isRootT1);

        while (!qNode.isEmpty()) {
            // Process the next node in the queue.
            int parent = qNode.remove();
            boolean isT1 = qIsT1.remove();

            if (isT1) {
                // Visit node only if not marked.
                if (!marked1[parent]) {
                    log.trace("Visiting node {} of type T1", parent);
                    // For each neighbor...
                    for (int nb = 0; nb < this.numNbsT1(parent); nb++) {
                        int e = this.edgeT1(parent, nb);
                        int child = this.childE(e);
                        if (!marked2[child]) {
                            // If the neighbor is not marked, queue the node and add the edge to
                            // the order.
                            qNode.add(child);
                            qIsT1.add(false);
                            ccorder.add(e);
                        }
                    }
                    // Mark the node as visited.
                    marked1[parent] = true;
                }
            } else {
                // Visit node only if not marked.
                if (!marked2[parent]) {
                    log.trace("Visiting node {} of type T2", parent);
                    // For each neighbor...
                    for (int nb = 0; nb < this.numNbsT2(parent); nb++) {
                        int e = this.edgeT2(parent, nb);
                        int child = this.childE(e);
                        if (!marked1[child]) {
                            // If the neighbor is not marked, queue the node and add the edge to
                            // the order.
                            qNode.add(child);
                            qIsT1.add(true);
                            ccorder.add(e);
                        }
                    }
                    // Mark the node as visited.
                    marked2[parent] = true;
                }
            }
        }
        return ccorder;
    }
679253
def inspect_node_neighborhood(nlinks, msinds, node_msindex):
    
    # seed_indexes = np.nonzero(node_seed)
    # selected_inds = msinds[seed_indexes]
    # node_msindex = selected_inds[0]

    node_neighbor_edges = get_neighborhood_edes(nlinks, node_msindex)

    node_neighbor_seeds = np.zeros_like(msinds, dtype=np.int8)
    for neighboor_ind in np.unique(node_neighbor_edges[:, :2].ravel()):
        node_neighbor_ind = np.where(msinds == neighboor_ind)
        node_neighbor_seeds[node_neighbor_ind] = 2

    node_neighbor_seeds[np.where(msinds == node_msindex)] = 1

    # node_coordinates = np.unravel_index(selected_voxel_ind, msinds.shape)
    # node_neighbor_coordinates = np.unravel_index(np.unique(node_neighbor_edges[:, :2].ravel()), msinds.shape)
    return node_neighbor_edges, node_neighbor_seeds
97955
public static List<String> getParameterNames(MethodNode node) {
        ArrayList<String> result = new ArrayList<String>();

        if (node.getParameters() != null) {
            for (Parameter parameter : node.getParameters()) {
                result.add(parameter.getName());
            }
        }
        return result;
    }
735400
public void addEdge(final Collection<HypergraphNode<T>> nodes) {
    final HypergraphEdge<T> edge = new HypergraphEdge<>(nodes);
    this.nodes.addAll(nodes);
    this.edges.add(edge);
  }
375193
function(node) {
		var hasNodes = false;

		if (node.hasChildNodes()) {
			for (var i = 0, len = node.childNodes.length; i < len; i++) {
				if (node.childNodes[i].nodeType === 1) {
					hasNodes = true;
					break;
				}
			}
		}

		return hasNodes;
	}
1081253
void connectTo(final Node<T> o) {
    if (!this.graph.equals(o.graph))
      throw new IllegalArgumentException("Cannot connect to nodes of two different graphs.");
    if (this.equals(o)) {
      return;
    }
    neighbours.add(o);
  }
580987
public static <T extends HierarchyEntity<T, ?>> List<T> getRoots(final List<T> nodes) {
    List<T> roots = CollectUtils.newArrayList();
    for (T m : nodes)
      if (null == m.getParent() || !nodes.contains(m.getParent())) roots.add(m);
    return roots;
  }
368286
public static void getTopicLinkIds(final Node node, final Set<String> linkIds) {
        // If the node is null then there isn't anything to find, so just return.
        if (node == null) {
            return;
        }

        if (node.getNodeName().equals("xref") || node.getNodeName().equals("link")) {
            final NamedNodeMap attributes = node.getAttributes();
            if (attributes != null) {
                final Node idAttribute = attributes.getNamedItem("linkend");
                if (idAttribute != null) {
                    final String idAttributeValue = idAttribute.getNodeValue();
                    linkIds.add(idAttributeValue);
                }
            }
        }

        final NodeList elements = node.getChildNodes();
        for (int i = 0; i < elements.getLength(); ++i) {
            getTopicLinkIds(elements.item(i), linkIds);
        }
    }
359721
public static List<Object> getChildren(TreeModel treeModel, Object node)
    {
        List<Object> children = new ArrayList<Object>();
        int n = treeModel.getChildCount(node);
        for (int i=0; i<n; i++)
        {
            Object child = treeModel.getChild(node, i);
            children.add(child);
        }
        return children;
    }
338410
public void setNodes(java.util.Collection<Node> nodes) {
        if (nodes == null) {
            this.nodes = null;
            return;
        }

        this.nodes = new java.util.ArrayList<Node>(nodes);
    }
1040772
public static boolean isLeaf(Node node) {
        return node instanceof Leaf || node.children() == null || node.children().size() == 0;
    }
171517
public static <T> List<T> toRoot(TreeDef.Parented<T> treeDef, T node) {
		List<T> list = new ArrayList<>();
		T tip = node;
		while (tip != null) {
			list.add(tip);
			tip = treeDef.parentOf(tip);
		}
		return list;
	}
1260945
public List<Node> findSiblings(Node node) {
      Preconditions.checkNotNull(node);
    
      Node parent = node.parent();
      if (null == parent) return null;

      return parent.childNodes();               
  }
81048
public static <T extends GraphNode<T>> int countAllDistinct(T node) {
        if (node == null) return 0;
        return collectAllNodes(node, new HashSet<T>()).size();
    }
128115
private static void getLeafNodes(
        TreeModel treeModel, Object node, Collection<Object> leafNodes)
    {
        if (node == null)
        {
            return;
        }
        int childCount = treeModel.getChildCount(node);
        if (childCount == 0)
        {
            leafNodes.add(node);
        }
        else
        {
            for (int i = 0; i < childCount; i++)
            {
                Object child = treeModel.getChild(node, i);
                getLeafNodes(treeModel, child, leafNodes);
            }
        }
    }
985791
def neighbors(self, node_id):
        """"""
        node = self.get_node(node_id)
        return [self.get_edge(edge_id)['vertices'][1] for edge_id in node['edges']]