Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/torch/graph.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSoumith Chintala <soumith@gmail.com>2015-08-05 14:41:01 +0300
committerSoumith Chintala <soumith@gmail.com>2015-08-05 14:41:01 +0300
commit83cbda2754268d82d55cca52f44b741d191909fe (patch)
treef83511af4fbf01ed798dfa3fbd17d252d466f8f8
parent2fc58236b5c9a22812e9f6b3b7cf14588053786f (diff)
parent11609f61838805ed454c4ab1dfaac7a1dcfac66f (diff)
Merge pull request #16 from torch/ffifix
removing ffi hard-dependency
-rw-r--r--graphviz.lua20
1 files changed, 16 insertions, 4 deletions
diff --git a/graphviz.lua b/graphviz.lua
index 847d2dd..a30fff6 100644
--- a/graphviz.lua
+++ b/graphviz.lua
@@ -1,7 +1,15 @@
-local ffi = require 'ffi'
require 'torch'
-ffi.cdef[[
+local ffiOk = false
+local graphvizOk = false
+local cgraphOk = false
+local ffi
+local graphviz
+local cgraph
+
+ffiOk, ffi = pcall(require, 'ffi')
+if ffiOk then
+ ffi.cdef[[
typedef struct FILE FILE;
typedef struct Agraph_s Agraph_t;
@@ -25,9 +33,13 @@ extern int gvRender(GVC_t *context, graph_t *g, const char *format, FILE *out);
extern int gvFreeLayout(GVC_t *context, graph_t *g);
extern int gvFreeContext(GVC_t *context);
]]
+ graphvizOk, graphviz = pcall(function() return ffi.load('libgvc') end)
+ cgraphOk, cgraph = pcall(function() return ffi.load('libcgraph') end)
+else
+ graphvizOk = false
+ cgraphOk = false
+end
-local graphvizOk, graphviz = pcall(function() return ffi.load('libgvc') end)
-local cgraphOk, cgraph = pcall(function() return ffi.load('libcgraph') end)
-- Retrieve attribute data from a graphviz object.
local function getAttribute(obj, name)