fix bugs
1. make global variables correctly
2. use fgraph.apply_nodes replace the previous fgraph.nodes