>>> import networkx as nx >>> arestes = [ ... ('ociós', 'cercant arbre', {'canvi' : 'espai en magatzem'}), ... ('cercant arbre', 'ociós', {'canvi' : 'magatzem ple'}), ... ('cercant arbre', 'tallant arbre', {'canvi' : 'arbre trobat'}), ... ('cercant arbre', 'morint', {'canvi' : 'energia=0'}), ... ('tallant arbre', 'recollint fusta', {'canvi' : 'arbre tallat'}), ... ('tallant arbre', 'morint', {'canvi' : 'energia=0'}), ... ('recollint fusta', 'cap al magatzem', {'canvi' : 'motxilla plena'}), ... ('recollint fusta', 'cercant arbre', {'canvi' : 'motxilla no plena'}), ... ('recollint fusta', 'morint', {'canvi' : 'energia=0'}), ... ('cap al magatzem', 'buidant motxilla', {'canvi' : 'al magatzem'}), ... ('cap al magatzem', 'morint', {'canvi' : 'energia=0'}), ... ('buidant motxilla', 'en espera', {'canvi' : 'magatzem ple'}), ... ('buidant motxilla', 'ociós', {'canvi' : 'motxilla buida'}), ... ('buidant motxilla', 'morint', {'canvi' : 'energia=0'}), ... ('en espera', 'buidant motxilla', {'canvi' : 'espai en magatzem'}), ... ] >>> g = nx.DiGraph(arestes) >>> from npc import parelles --ini-enunciat >>> parelles(g) [('buidant motxilla', 'en espera'), ('cercant arbre', 'ociós')] >>> g.add_edge('cap al magatzem', 'recollint fusta', canvi='ensopega') >>> parelles(g) [('buidant motxilla', 'en espera'), ('cap al magatzem', 'recollint fusta'), ('cercant arbre', 'ociós')] --fi-enunciat >>> g.add_edge('tallant arbre', 'cercant arbre', canvi='arbre es crema') >>> parelles(g) [('buidant motxilla', 'en espera'), ('cap al magatzem', 'recollint fusta'), ('cercant arbre', 'ociós'), ('cercant arbre', 'tallant arbre')] >>> g.remove_node('cercant arbre') >>> parelles(g) [('buidant motxilla', 'en espera'), ('cap al magatzem', 'recollint fusta')]