Advertisement
STANAANDREY

print arches of oriented graph

Nov 11th, 2022 (edited)
934
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.37 KB | None | 0 0
  1. from collections.abc import *
  2. from functools import reduce
  3.  
  4. def print_arcs(graph: Mapping[Set]):
  5.    
  6.     def redFn1(acc, elem):
  7.         def redFn2(acc2, elem2):
  8.             print(f"{elem}->{elem2}")
  9.         reduce(redFn2, graph[elem], None)
  10.     reduce(redFn1, graph, None)
  11.  
  12.  
  13. g = {
  14.     'a': {'b', 'c', 'c'},
  15.     'ef': {'c'},
  16.     'c': {'b'}
  17. }
  18. print_arcs(g)
  19.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement