SNAP Library 2.0, User Reference
2013-05-13 16:33:57
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
|
00001 00002 // GraphViz 00003 namespace TSnap { 00004 namespace TSnapDetail { 00005 void GVizDoLayout(const TStr& GraphInFNm, TStr OutFNm, const TGVizLayout& Layout) { 00006 TStr LayoutExe = TSnap::TSnapDetail::GVizGetLayoutStr(Layout), Ext = OutFNm.GetFExt(), GvPath; 00007 #if defined(GLib_WIN) 00008 GvPath = "C:\\Prog\\GraphViz\\bin\\"; 00009 #else 00010 GvPath = "/usr/bin/"; 00011 //OutFNm = OutFNm.GetFMid() + Ext; 00012 #endif 00013 IAssert(Ext==".ps" || Ext==".gif" || Ext==".png"); 00014 const TStr ExeCmd = TStr::Fmt("%s -T%s %s -o %s", LayoutExe.CStr(), 00015 Ext.CStr()+1, GraphInFNm.CStr(), OutFNm.CStr()); 00016 00017 if (system(ExeCmd.CStr())==0) { return; } 00018 #if defined(GLib_WIN) 00019 if (system(TStr::Fmt(".\\%s", ExeCmd.CStr()).CStr())==0) { return; } 00020 #else 00021 if (system(TStr::Fmt("./%s", ExeCmd.CStr()).CStr())==0) { return; } 00022 #endif 00023 if (system(TStr::Fmt("%s%s", GvPath.CStr(), ExeCmd.CStr()).CStr())==0) { return; } 00024 fprintf(stderr, "[%s:%d] Cannot find GraphViz (%s). Set the PATH.\n", __FILE__, __LINE__, ExeCmd.CStr()); 00025 //#if defined(GLib_WIN) 00026 //if (ShowPlot) system(TStr::Fmt("start %s", OutFNm.CStr()).CStr()); 00027 //#endif 00028 } 00029 00030 TStr GVizGetLayoutStr(const TGVizLayout& Layout) { 00031 switch(Layout) { 00032 case gvlDot : return "dot"; 00033 case gvlNeato : return "neato"; 00034 case gvlTwopi : return "twopi"; 00035 case gvlCirco: return "circo"; 00036 default: Fail; 00037 } 00038 return TStr::GetNullStr(); 00039 } 00040 00041 } // namespace TSnapDetail 00042 } // namespace TSnap 00043