A graph rewriting system for levelgraph