How to get all the nodes and edges from Digraph graphViz

I have stored a set of graphs into a digraph obj. Now, I want to iterate over the edges and nodes. Also, want to know how can I get the edges src and target. But I tried a couple of ways and couldn’t do it e.g.,

for tail, head in graph.iteredges():

or,

graph.edges()

or,

graph.iteredges()

I am on ubuntu,
Python library (graphviz.__version__) is 0.19.1
and graphviz version is,

$ dot -v
dot - graphviz version 2.40.1 (20161225.0304)
libdir = "/usr/lib/x86_64-linux-gnu/graphviz"
Activated plugin library: libgvplugin_dot_layout.so.6
Using layout: dot:dot_layout
Activated plugin library: libgvplugin_core.so.6
Using render: dot:core
Using device: dot:dot:core
The plugin configuration file:
	/usr/lib/x86_64-linux-gnu/graphviz/config6a
		was successfully loaded.
    render	:  cairo dot dot_json fig gd json json0 map mp pic pov ps svg tk vml vrml xdot xdot_json
    layout	:  circo dot fdp neato nop nop1 nop2 osage patchwork sfdp twopi
    textlayout	:  textlayout
    device	:  canon cmap cmapx cmapx_np dot dot_json eps fig gd gd2 gif gv imap imap_np ismap jpe jpeg jpg json json0 mp pdf pic plain plain-ext png pov ps ps2 svg svgz tk vml vmlz vrml wbmp x11 xdot xdot1.2 xdot1.4 xdot_json xlib
    loadimage	:  (lib) eps gd gd2 gif jpe jpeg jpg png ps svg xbm

In Python, you might find the third-party Pygraphviz easier to use than the bundled Graphviz bindings.

Also, the graphviz gvpr processor is like awk or sed for graphviz graphs, as shown in the following session. E means to match edges. $ is the current match. tail and head are, well, anyway you get the idea, and you can find docs and examples online. It’s good for some small tasks.

$ cat t.gv
digraph G { a -> b; c -> d }
$ gvpr 'E {print("edge from ", $.tail, " to ", $.head);}' <t.gv
edge from a to b
edge from c to d
$