original_docstring: Neighbor Subgraph
      
      Given a Graph and a node list returns the subgraph generated with the nodes
      in the node dict, the first neighbors of those nodes, and the edges between
      them
      
      
      Parameters:
          :kegg_graph (Graph): input graph, has to be generated via kegg_link_graph()
          :node_dict (dict): dict of input nodes
          :name (str): optional, name of the graph
          
      Returns:
          :neighbor_graph (Graph): graph of node_dict, first neighbors of those nodes\
          and edges between them
      .. seealso:: kegg_link_graph()
      
docstring: Neighbor Subgraph
  Given a Graph and a node list returns the subgraph generated with the nodes
  in the node dict, the first neighbors of those nodes, and the edges between
  them
docstring_tokens: Neighbor Subgraph Given a Graph and a node list returns the subgraph generated with the nodes in the node dict the first neighbors of those nodes and the edges between them
code: def neighbor_graph(graph, node_dict, name=None, keep_isolated_nodes=False):
      """Neighbor Subgraph
      
      Given a Graph and a node list returns the subgraph generated with the nodes
      in the node dict, the first neighbors of those nodes, and the edges between
      them
      
      
      Parameters:
          :kegg_graph (Graph): input graph, has to be generated via kegg_link_graph()
          :node_dict (dict): dict of input nodes
          :name (str): optional, name of the graph
          
      Returns:
          :neighbor_graph (Graph): graph of node_dict, first neighbors of those nodes\
          and edges between them
      .. seealso:: kegg_link_graph()
      """
  
      nodeset = set()
  
      input_nodes_set = set(node_dict.keys())
  
      try:
          nx.get_node_attributes(graph, "nodetype")
      except:
          NotAKeggGraphError(graph)
  
      nodeset.update(input_nodes_set)
  
      for node in input_nodes_set:
          try:
              nodeset.update(list(graph[node]))
          except KeyError:
              pass
  
      # we already have attributes for nodes in graph
      neighbor_graph = nx.Graph.copy(nx.subgraph(graph, nodeset))
  
      # ok now we want to add input nodes that are left behind
      if keep_isolated_nodes == True:
          difference_set = input_nodes_set - set(neighbor_graph.nodes)
  
          for node in difference_set:
              neighbor_graph.add_node(node, nodetype=node_dict[node], label = node)
  
      if name is None:
          name = "neighbor_graph_of_{}".format(graph.name)
  
      neighbor_graph.name = name
  
      return neighbor_graph
code_tokens: def neighbor_graph ( graph , node_dict , name = None , keep_isolated_nodes = False ) : nodeset = set ( ) input_nodes_set = set ( node_dict . keys ( ) ) try : nx . get_node_attributes ( graph , "nodetype" ) except : NotAKeggGraphError ( graph ) nodeset . update ( input_nodes_set ) for node in input_nodes_set : try : nodeset . update ( list ( graph [ node ] ) ) except KeyError : pass neighbor_graph = nx . Graph . copy ( nx . subgraph ( graph , nodeset ) ) if keep_isolated_nodes == True : difference_set = input_nodes_set - set ( neighbor_graph . nodes ) for node in difference_set : neighbor_graph . add_node ( node , nodetype = node_dict [ node ] , label = node ) if name is None : name = "neighbor_graph_of_{}" . format ( graph . name ) neighbor_graph . name = name return neighbor_graph
short_docstring: Neighbor Subgraph
  Given a Graph and a node list returns the subgraph generated with the nodes
  in the node dict, the first neighbors of those nodes, and the edges between
  them
short_docstring_tokens: Neighbor Subgraph Given a Graph and a node list returns the subgraph generated with the nodes in the node dict the first neighbors of those nodes and the edges between them
comment: """Neighbor Subgraph
      
      Given a Graph and a node list returns the subgraph generated with the nodes
      in the node dict, the first neighbors of those nodes, and the edges between
      them
      
      
      Parameters:
          :kegg_graph (Graph): input graph, has to be generated via kegg_link_graph()
          :node_dict (dict): dict of input nodes
          :name (str): optional, name of the graph
          
      Returns:
          :neighbor_graph (Graph): graph of node_dict, first neighbors of those nodes\
          and edges between them
      .. seealso:: kegg_link_graph()
      """$SEP$# we already have attributes for nodes in graph$SEP$# ok now we want to add input nodes that are left behind