Depends on How you like your Graph Editor. I used to have it floating. But by the time I used a Graph-Editor-layout more and more. Floating stuff is crap now :]
method 1: check if "graphEditor1Window" exists, delete it, if not create it:
CODE
if (window -q -ex graphEditor1Window)
deleteUI graphEditor1Window;
else
tearOffPanel "Graph Editor" "graphEditor" true;
method 2: look if the panel "graphEditor1" is visible, turn on another layout, if not turn on a Graph-Editor Layout:CODE
{
int $graphEditorFound = 0;
for ($panel in getPanel -visiblePanels)
if ($panel == "graphEditor1")
$graphEditorFound = 1;
if ($graphEditorFound)
setNamedPanelLayout "Persp/Outliner";
else
setNamedPanelLayout "Outl_Graph_Persp";
}
method 2 is longer because actually the panel always exists! And you cannot query directly if its visible. You see in method 1 Its not "created" its just teared off ;]
have phun