|
| 1 | +from typing import List, Tuple |
| 2 | + |
| 3 | +def mec_size(cpdag: List[Tuple[int, int]]) -> int: |
| 4 | + """ |
| 5 | + Compute the number of DAGs in the Markov equivalence class represented by the CPDAG. |
| 6 | +
|
| 7 | + Parameters |
| 8 | + ----------- |
| 9 | + cpdag: A list of tuples representing the edges of the CPDAG, where each tuple is a pair of integers (vertex1, vertex2). Undirected edges are encoded by including both (a, b) and (b, a). |
| 10 | +
|
| 11 | + Returns |
| 12 | + ------- |
| 13 | + An integer representing the number of DAGs. |
| 14 | + """ |
| 15 | + ... |
| 16 | + |
| 17 | +def mec_sample_dags( |
| 18 | + cpdag: List[Tuple[int, int]], k: int |
| 19 | +) -> List[List[Tuple[int, int]]]: |
| 20 | + """ |
| 21 | + Sample k DAGs uniformly from the Markov equivalence class represented by the CPDAG. |
| 22 | +
|
| 23 | + Parameters |
| 24 | + ----------- |
| 25 | + cpdag: A list of tuples representing the edges of the CPDAG, where each tuple is a pair of integers (vertex1, vertex2). Undirected edges are encoded by including both (a, b) and (b, a). |
| 26 | + k: The number of DAGs to sample. |
| 27 | +
|
| 28 | + Returns |
| 29 | + ------- |
| 30 | + A list of DAGs, where each DAG is represented as a list of tuples (edges). |
| 31 | + """ |
| 32 | + ... |
| 33 | + |
| 34 | +def mec_sample_orders(cpdag: List[Tuple[int, int]], k: int) -> List[List[int]]: |
| 35 | + """ |
| 36 | + Sample k DAGs (represented by a topological order) uniformly from the Markov equivalence class represented by the CPDAG. |
| 37 | +
|
| 38 | + Parameters |
| 39 | + ----------- |
| 40 | + cpdag: A list of tuples representing the edges of the CPDAG, where each tuple is a pair of integers (vertex1, vertex2). Undirected edges are encoded by including both (a, b) and (b, a). |
| 41 | + k: The number of DAGs to sample. |
| 42 | +
|
| 43 | + Returns |
| 44 | + ------- |
| 45 | + A list of topological orders, where each topological order is represented as a list of integers (vertex indices). |
| 46 | + """ |
| 47 | + ... |
| 48 | + |
| 49 | +def mec_list_dags(cpdag: List[Tuple[int, int]]) -> List[List[Tuple[int, int]]]: |
| 50 | + """ |
| 51 | + List all DAGs in the Markov equivalence class represented by the CPDAG. |
| 52 | +
|
| 53 | + Parameters |
| 54 | + ----------- |
| 55 | + cpdag: A list of tuples representing the edges of the CPDAG, where each tuple is a pair of integers (vertex1, vertex2). Undirected edges are encoded by including both (a, b) and (b, a). |
| 56 | +
|
| 57 | + Returns |
| 58 | + ------- |
| 59 | + A list of DAGs, where each DAG is represented as a list of tuples (edges). |
| 60 | + """ |
| 61 | + ... |
| 62 | + |
| 63 | +def mec_list_orders(cpdag: List[Tuple[int, int]]) -> List[List[int]]: |
| 64 | + """ |
| 65 | + List all DAGs (represented by a topological order) in the Markov equivalence class represented by the CPDAG. |
| 66 | +
|
| 67 | + Parameters |
| 68 | + ----------- |
| 69 | + cpdag: A list of tuples representing the edges of the CPDAG, where each tuple is a pair of integers (vertex1, vertex2). Undirected edges are encoded by including both (a, b) and (b, a). |
| 70 | +
|
| 71 | + Returns |
| 72 | + ------- |
| 73 | + A list of topological orders, where each topological order is represented as a list of integers (vertex indices). |
| 74 | + """ |
| 75 | + ... |
0 commit comments