>>> 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 llista_canvis --ini-enunciat >>> llista_canvis(g, 'ociós', 'tallant arbre') ['espai en magatzem', 'arbre trobat'] >>> llista_canvis(g, 'morint', 'tallant arbre') [] >>> llista_canvis(g, 'cercant arbre', 'buidant motxilla') ['arbre trobat', 'arbre tallat', 'motxilla plena', 'al magatzem'] --fi-enunciat >>> llista_canvis(g, 'tallant arbre', 'ociós') ['arbre tallat', 'motxilla no plena', 'magatzem ple'] >>> g.add_edge('morint', 'ociós', canvi='ressuscita') >>> llista_canvis(g, 'tallant arbre', 'ociós') ['energia=0', 'ressuscita']