public void OpenGraphWindow(Graph graph)
        {
            GraphEditor window = null;

            int _id = graph.GetInstanceID();

            // check if other graph windows are already open
            // happens if user has closed unity and left some graph windows open
            // then we have to add them to the graphwindows list again.
            if (graphWindows.Count == 0 || graphWindows == null)
            {
                GraphEditor[] _w = Resources.FindObjectsOfTypeAll <GraphEditor>();

                if (_w.Length > 0)
                {
                    //Debug.Log(_w.Length);

                    for (int w = 0; w < _w.Length; w++)
                    {
                        graphWindows.Add(new GraphWindows(_w[w].rootGraph.GetInstanceID(), _w[w]));
                    }
                }
            }

            for (int i = 0; i < graphWindows.Count; i++)
            {
                if (graphWindows[i].id == _id)
                {
                    window = graphWindows[i].graphEditor;
                }
            }

            if (window != null)
            {
                window.Init(window, graph);
                window.Focus();
            }
            else
            {
                //window = CreateInstance<GraphEditor>();
                window = (GraphEditor)EditorWindow.CreateWindow <GraphEditor>(typeof(GraphEditor));
                graphWindows.Add(new GraphWindows(graph.GetInstanceID(), window));
                window.Init(window, graph);
            }

            // Check if graph needs to be updated
            GraphUpdater.UpdateGraph(graph);

            EditorUtility.SetDirty(this);
        }