'How to add node color as attributes using Network X

How do I store NetworkX output not as .png or image files, but as an analyzable format with color as node attribute?

Below are the code used to draw NetworkX graph.

draw_networkx(
        graph,
        pos=graph.graph['positions'],
        node_color=graph.graph['colors'],
        labels=graph.graph['labels'],
        label=example_presentation,
        font_size=8,
        node_size=800
    )

graph.graph['colors'] is

['#5B9BD5',
 '#E7E6E6',
 '#ff0000',
 '#70AD47',
 '#E7E6E6',
 '#ff0000',
 '#70AD47',
 '#E7E6E6',
 '#E7E6E6',
 '#E7E6E6',
 '#E7E6E6',
 '#E7E6E6',
 '#E7E6E6']


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source