class_docstr: Class for representing PDAGs (also known as CPDAG). PDAGs are the equivalence classes of
  DAGs and contain both directed and undirected edges.
  
  Note: In this class, undirected edges are represented using two edges in both direction i.e.
  an undirected edge between X - Y is represented using X -> Y and X <- Y.
class_docstr_tok: ["Class","for","representing","PDAGs","(","also","known","as","CPDAG",")",".","PDAGs","are","the","equivalence","classes","of","DAGs","and","contain","both","directed","and","undirected","edges",".","Note",":","In","this","class",",","undirected","edges","are","represented","using","two","edges","in","both","direction","i.e",".","an","undirected","edge","between","X","-","Y","is","represented","using","X","-",">","Y","and","X","<","-","Y","."]
docstr: Returns one possible DAG which is represented using the PDAG.
  
  Parameters
  ----------
  required_edges: list, array-like of 2-tuples
      The list of edges that should be included in the DAG.
  
  Returns
  -------
  Returns an instance of DAG.
  
  Examples
  --------
docstr_tok: ["Returns","one","possible","DAG","which","is","represented","using","the","PDAG",".","Parameters","--","--","--","--","--","required_edges",":","list",",","array-like","of","2-tuples","The","list","of","edges","that","should","be","included","in","the","DAG",".","Returns","--","--","--","-","Returns","an","instance","of","DAG",".","Examples","--","--","--","--"]
code: def to_dag(self, required_edges=[]):
      """
      Returns one possible DAG which is represented using the PDAG.
  
      Parameters
      ----------
      required_edges: list, array-like of 2-tuples
          The list of edges that should be included in the DAG.
  
      Returns
      -------
      Returns an instance of DAG.
  
      Examples
      --------
  
      """
      # Add required edges if it doesn't form a new v-structure or an opposite edge
      # is already present in the network.
      dag = DAG()
      # Add all the nodes and the directed edges
      dag.add_nodes_from(self.nodes())
      dag.add_edges_from(self.directed_edges)
      dag.latents = self.latents
  
      pdag = self.copy()
      while pdag.number_of_nodes() > 0:
          # find node with (1) no directed outgoing edges and
          #                (2) the set of undirected neighbors is either empty or
          #                    undirected neighbors + parents of X are a clique
          found = False
          for X in pdag.nodes():
              directed_outgoing_edges = set(pdag.successors(X)) - set(
                  pdag.predecessors(X)
              )
              undirected_neighbors = set(pdag.successors(X)) & set(
                  pdag.predecessors(X)
              )
              neighbors_are_clique = all(
                  (
                      pdag.has_edge(Y, Z)
                      for Z in pdag.predecessors(X)
                      for Y in undirected_neighbors
                      if not Y == Z
                  )
              )
  
              if not directed_outgoing_edges and (
                  not undirected_neighbors or neighbors_are_clique
              ):
                  found = True
                  # add all edges of X as outgoing edges to dag
                  for Y in pdag.predecessors(X):
                      dag.add_edge(Y, X)
                  pdag.remove_node(X)
                  break
  
          if not found:
              logger.warning(
                  "PDAG has no faithful extension (= no oriented DAG with the "
                  + "same v-structures as PDAG). Remaining undirected PDAG edges "
                  + "oriented arbitrarily."
              )
              for X, Y in pdag.edges():
                  if not dag.has_edge(Y, X):
                      try:
                          dag.add_edge(X, Y)
                      except ValueError:
                          pass
              break
      return dag
  
imports: import itertools
  import networkx
  import numpy
  from pgmpy.base import UndirectedGraph
  from pgmpy.global_vars import logger
  from pgmpy.independencies import Independencies
label_desc: Use image node_id 3 for calling the PDAG obj's underlying member method code with example usage: obj.to_dag(required_edges) and returns: dag