generate graph dynamically