Example #1
0
def new_local_graph():
    try:
        from java.lang import Exception as JException
    except ImportError:
        raise RuntimeError, 'To acess WebGraph data you need to run this with jython.'
    else:
        from pywebgraph.webgraph.local import Graph
        return Graph()
Example #2
0
def new_remote_graph(address=None):
    from pywebgraph.webgraph.client import Graph
    import xmlrpclib
    import socket
    graph = Graph(address)
    try:
        graph.current_node
    except xmlrpclib.Fault:
        pass
    except socket.error:
        raise RuntimeError, "pyWebGraph XML-RPC server at not responding."
        graph = None
    except:
        raise
    return graph
Example #3
0
# pyWebGraph is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with pyWebGraph.  If not, see <http://www.gnu.org/licenses/>.

if __name__ == "__main__":

    from sys import argv

    from pywebgraph.webgraph.local import Graph

    maxint = float("inf")
    graph = Graph()
    graph.load_graph(argv[1])

    queue = []
    dist = [maxint for i in range(graph.num_nodes)]
    ecc = 0

    lo = 0
    hi = graph.num_nodes

    for i in range(lo, hi):

        if dist[i] == maxint:

            queue.append(i)
            dist[i] = 0
Example #4
0
# pyWebGraph is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with pyWebGraph.  If not, see <http://www.gnu.org/licenses/>.

if __name__ == "__main__":

    from sys import argv

    from pywebgraph.ubigraph import Renderer
    from pywebgraph.webgraph.local import Graph

    graph = Graph()
    graph.load_graph(argv[1])
    renderer = Renderer()

    def callback(u):
        try:
            for v in graph.outlinks(u):
                if u == v:
                    continue
                renderer.addedge(u, v)
        except Exception as e:
            print(e)
            return -1
        return 0

    import random
Example #5
0
# pyWebGraph is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with pyWebGraph.  If not, see <http://www.gnu.org/licenses/>.

if __name__ == '__main__':

	from sys import argv
	
	from pywebgraph.ubigraph import Renderer
	from pywebgraph.webgraph.local import Graph
	
	graph = Graph()
	graph.load_graph( argv[ 1 ] )
	renderer = Renderer()
	
	def callback( u ):
		try:
			for v in graph.outlinks( u ):
				if ( u == v ): continue
				renderer.addedge( u, v )
		except:
			return -1
		return 0

	import random
	from SimpleXMLRPCServer import SimpleXMLRPCServer