Make edges return endpoint pairs #158
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Snippet Review | |
| on: | |
| push: | |
| paths: | |
| - "include/**" | |
| - "snippet/**" | |
| - "main.py" | |
| - "main_boost.cpp" | |
| - "main_nxpp.cpp" | |
| - "scripts/unix/test_single_snippet.sh" | |
| - ".github/workflows/snippet-review.yml" | |
| pull_request: | |
| paths: | |
| - "include/**" | |
| - "snippet/**" | |
| - "main.py" | |
| - "main_boost.cpp" | |
| - "main_nxpp.cpp" | |
| - "scripts/unix/test_single_snippet.sh" | |
| - ".github/workflows/snippet-review.yml" | |
| workflow_dispatch: | |
| jobs: | |
| snippets: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Set up Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: '3.12' | |
| - name: Install system dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y libboost-graph-dev | |
| - name: Install Python dependencies | |
| run: python -m pip install --upgrade pip networkx scipy | |
| - name: Run snippet review | |
| shell: bash | |
| run: | | |
| set -uo pipefail | |
| overall_status=0 | |
| summary_file="$(mktemp)" | |
| describe_snippet() { | |
| case "$1" in | |
| 2sat) echo "2-SAT satisfiability via implication graph SCCs" ;; | |
| bellman_ford) echo "Single-source shortest paths with Bellman-Ford" ;; | |
| bfs) echo "Breadth-first search traversal events" ;; | |
| cc) echo "Connected components in an undirected graph" ;; | |
| centrality) echo "Degree, PageRank, and betweenness centrality on one graph" ;; | |
| dag_sp) echo "Single-source shortest paths in a DAG" ;; | |
| dfs) echo "Depth-first search traversal events" ;; | |
| dijkstra) echo "Single-source shortest paths with Dijkstra" ;; | |
| dot) echo "Graphviz DOT export for a small directed graph" ;; | |
| flow) echo "Maximum flow on a capacitated directed graph" ;; | |
| floyd_warshall) echo "All-pairs shortest paths with Floyd-Warshall" ;; | |
| graph_example) echo "Basic directed graph construction and edge iteration" ;; | |
| graph_weights) echo "Weighted graph construction and weight inspection" ;; | |
| kruskal) echo "Minimum spanning tree with Kruskal" ;; | |
| mcmf_cc) echo "Min-cost max-flow via push-relabel and cycle canceling" ;; | |
| mcmf_ssp) echo "Min-cost max-flow via successive shortest paths" ;; | |
| prim) echo "Minimum spanning tree with Prim" ;; | |
| scc) echo "Strongly connected components in a directed graph" ;; | |
| scc_named) echo "Strongly connected components with representative mapping" ;; | |
| ts) echo "Topological sorting of a DAG" ;; | |
| *) echo "Snippet parity check across implementations" ;; | |
| esac | |
| } | |
| { | |
| echo "## Snippet Review" | |
| echo | |
| echo "| Snippet | Description | Result |" | |
| echo "|---|---|---|" | |
| } > "$summary_file" | |
| for dir in snippet/*/; do | |
| snippet_name="$(basename "$dir")" | |
| snippet_description="$(describe_snippet "$snippet_name")" | |
| echo "Running snippet review for $snippet_name" | |
| if bash scripts/unix/test_single_snippet.sh "$snippet_name"; then | |
| echo "| \`$snippet_name\` | $snippet_description | PASS |" >> "$summary_file" | |
| else | |
| echo "| \`$snippet_name\` | $snippet_description | FAIL |" >> "$summary_file" | |
| latest_run_dir="$(ls -dt logs/snippet/${snippet_name}_* 2>/dev/null | head -n 1 || true)" | |
| if [[ -n "$latest_run_dir" && -f "$latest_run_dir/run.log" ]]; then | |
| echo "::group::${snippet_name} failure log" | |
| sed -n '1,220p' "$latest_run_dir/run.log" | |
| echo "::endgroup::" | |
| fi | |
| if [[ -n "$latest_run_dir" ]]; then | |
| shopt -s nullglob | |
| compile_errs=("$latest_run_dir"/*.compile.err) | |
| shopt -u nullglob | |
| for compile_err in "${compile_errs[@]}"; do | |
| if [[ -s "$compile_err" ]]; then | |
| echo "::group::$(basename "$compile_err")" | |
| sed -n '1,220p' "$compile_err" | |
| echo "::endgroup::" | |
| fi | |
| done | |
| fi | |
| overall_status=1 | |
| fi | |
| done | |
| cat "$summary_file" >> "$GITHUB_STEP_SUMMARY" | |
| if [[ "$overall_status" -ne 0 ]]; then | |
| exit 1 | |
| fi |