Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C图形库_C_Ruby_Directed Acyclic Graphs_Ruby C Extension - Fatal编程技术网

C图形库

C图形库,c,ruby,directed-acyclic-graphs,ruby-c-extension,C,Ruby,Directed Acyclic Graphs,Ruby C Extension,有一个很好的图论操作C库吗?我特别需要计算一个有向图的。我在Ruby中实现了以下功能: def strongly_connected_components graph @index, @stack, @indice, @lowlink, @scc = 0, [], {}, {}, [] @graph = graph vertices(@graph).each{|v| strong_connect(v) unless @indice[v]}

有一个很好的图论操作C库吗?我特别需要计算一个有向图的。我在Ruby中实现了以下功能:

    def strongly_connected_components graph
        @index, @stack, @indice, @lowlink, @scc = 0, [], {}, {}, []
        @graph = graph
        vertices(@graph).each{|v| strong_connect(v) unless @indice[v]}
        @scc
    end
    def strong_connect v
        @indice[v] = @index
        @lowlink[v] = @index
        @index += 1
        @stack.push(v)
        @graph.each do |vv, w|
            next unless vv == v
            if !@indice[w]
                strong_connect(w)
                @lowlink[v] = [@lowlink[v], @lowlink[w]].min
            elsif @stack.include?(w)
                @lowlink[v] = [@lowlink[v], @indice[w]].min
            end
        end
        if @lowlink[v] == @indice[v]
            i = @stack.index(v)
            @scc.push(@stack[i..-1])
            @stack = @stack[0...i]
        end
    end
它使用的是小图,但随着图变大,由于递归调用方法
strong\u connect
,它开始返回“stack level too deep”错误。我想我需要一个C库并从Ruby访问它,主程序就是在Ruby中编写的


除了图书馆外,在Ruby图书馆使用任何建议都是有帮助的。

< P>(Ruby)是一个可以考虑的选项。

< P>我遇到了图书馆。它是用C编写的,有Ruby、Python和R的包装。对你来说,这意味着你可以在享受Ruby带来的舒适感的同时享受C的速度。

它需要C吗?有人告诉我,如果你对C++有把握,那就是方法。只要米迦勒可以从Ruby调用,那就没问题了。我只是不熟悉使用其他语言扩展Ruby。你知道怎么称呼Ruby吗?对不起,我不知道。我几乎没用过Ruby。你知道这个库的可伸缩性吗?因为我也在Ruby中实现了相同的算法,并且遇到了一个问题,所以我担心这个库也是用Ruby编写的。可能有一种方法可以避免我遇到的问题。我不知道。@sawa:我不知道它的可扩展性。