class_docstr: A space representing graph information as a series of `nodes` connected with `edges` according to an adjacency matrix represented as a series of `edge_links`.
  
  Example usage::
  
      self.observation_space = spaces.Graph(node_space=space.Box(low=-100, high=100, shape=(3,)), edge_space=spaces.Discrete(3))
class_docstr_tok: ["A","space","representing","graph","information","as","a","series","of","`","nodes","`","connected","with","`","edges","`","according","to","an","adjacency","matrix","represented","as","a","series","of","`","edge_links","`",".","Example","usage",":",":","self.observation_space","=","spaces.Graph","(","node_space=space.Box","(","low=-100",",","high=100",",","shape=","(","3",",",")",")",",","edge_space=spaces.Discrete","(","3",")",")"]
docstr: Return boolean specifying if x is a valid member of this space.
docstr_tok: ["Return","boolean","specifying","if","x","is","a","valid","member","of","this","space","."]
code: def contains(self, x: GraphInstance) -> bool:
      """Return boolean specifying if x is a valid member of this space."""
      if isinstance(x, GraphInstance):
          # Checks the nodes
          if isinstance(x.nodes, np.ndarray):
              if all(node in self.node_space for node in x.nodes):
                  # Check the edges and edge links which are optional
                  if isinstance(x.edges, np.ndarray) and isinstance(
                      x.edge_links, np.ndarray
                  ):
                      assert x.edges is not None
                      assert x.edge_links is not None
                      if self.edge_space is not None:
                          if all(
                              edge in self.edge_space
                              for edge in x.edges
                          ):
                              if np.issubdtype(
                                  x.edge_links.dtype, np.integer
                              ):
                                  if x.edge_links.shape == (
                                      len(x.edges),
                                      2,
                                  ):
                                      if np.all(
                                          np.logical_and(
                                              x.edge_links >= 0,
                                              x.edge_links
                                              < len(x.nodes),
                                          )
                                      ):
                                          return True
                  else:
                      return x.edges is None and x.edge_links is None
      return False
  
file_path: gym/gym/spaces/graph.py
imports: from typing import NamedTuple, Optional, Sequence, Tuple, Union
  import numpy
  from gym.logger import warn
  from gym.spaces.box import Box
  from gym.spaces.discrete import Discrete
  from gym.spaces.multi_discrete import MultiDiscrete
  from gym.spaces.space import Space
label_desc: Use image node_id 5 for calling the Graph obj's underlying member method code with example usage: obj.contains(x) and returns: False, unknown, True