當前位置: 首頁>>代碼示例>>Python>>正文


Python networkx.__version__方法代碼示例

本文整理匯總了Python中networkx.__version__方法的典型用法代碼示例。如果您正苦於以下問題:Python networkx.__version__方法的具體用法?Python networkx.__version__怎麽用?Python networkx.__version__使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在networkx的用法示例。


在下文中一共展示了networkx.__version__方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: check6_bsddb3

# 需要導入模塊: import networkx [as 別名]
# 或者: from networkx import __version__ [as 別名]
def check6_bsddb3(self):
        '''bsddb3 - Python Bindings for Oracle Berkeley DB

        requires Berkeley DB

        PY_BSDDB3_VER_MIN = (6, 0, 1) # 6.x series at least
        '''
        self.append_text("\n")
        # Start check

        try:
            import bsddb3 as bsddb
            bsddb_str = bsddb.__version__  # Python adaptation layer
            # Underlying DB library
            bsddb_db_str = str(bsddb.db.version()).replace(', ', '.')\
                .replace('(', '').replace(')', '')
        except ImportError:
            bsddb_str = 'not found'
            bsddb_db_str = 'not found'

        result = ("* Berkeley Database library (bsddb3: " + bsddb_db_str +
                  ") (Python-bsddb3 : " + bsddb_str + ")")
        # End check
        self.append_text(result) 
開發者ID:gramps-project,項目名稱:addons-source,代碼行數:26,代碼來源:PrerequisitesCheckerGramplet.py

示例2: check_fontconfig

# 需要導入模塊: import networkx [as 別名]
# 或者: from networkx import __version__ [as 別名]
def check_fontconfig(self):
        ''' The python-fontconfig library is used to support the Genealogical
        Symbols tab of the Preferences.  Without it Genealogical Symbols don't
        work '''
        try:
            import fontconfig
            vers = fontconfig.__version__
            if vers.startswith("0.5."):
                result = ("* python-fontconfig " + vers +
                          " (Success version 0.5.x is installed.)")
            else:
                result = ("* python-fontconfig " + vers +
                          " (Requires version 0.5.x)")
        except ImportError:
            result = "* python-fontconfig Not found, (Requires version 0.5.x)"
        # End check
        self.append_text(result)

    #Optional 
開發者ID:gramps-project,項目名稱:addons-source,代碼行數:21,代碼來源:PrerequisitesCheckerGramplet.py

示例3: check23_pedigreechart

# 需要導入模塊: import networkx [as 別名]
# 或者: from networkx import __version__ [as 別名]
def check23_pedigreechart(self):
        '''PedigreeChart - Can optionally use - NumPy if installed

        https://github.com/gramps-project/addons-source/blob/master/PedigreeChart/PedigreeChart.py
        '''
        self.append_text("\n")
        self.render_text("""<b>03. <a href="https://gramps-project.org/wiki"""
                         """/index.php?title=PedigreeChart">"""
                         """Addon:PedigreeChart</a> :</b> """)
        # Start check

        try:
            import numpy
            numpy_ver = str(numpy.__version__)
            #print("numpy.__version__ :" + numpy_ver )
            # NUMPY_check = True
        except ImportError:
            numpy_ver = "Not found"
            # NUMPY_check = False

        result = "(NumPy : " + numpy_ver + " )"
        # End check
        self.append_text(result)
        #self.append_text("\n") 
開發者ID:gramps-project,項目名稱:addons-source,代碼行數:26,代碼來源:PrerequisitesCheckerGramplet.py

示例4: print_versions

# 需要導入模塊: import networkx [as 別名]
# 或者: from networkx import __version__ [as 別名]
def print_versions(file: typing.TextIO = None) -> None:
    """
    Print version strings of currently installed dependencies

     ``> python -m quantumflow.meta``


    Args:
        file: Output stream. Defaults to stdout.
    """

    print('** QuantumFlow dependencies (> python -m quantumflow.meta) **')
    print('quantumflow \t', qf.__version__, file=file)
    print('python      \t', sys.version[0:5], file=file)
    print('numpy       \t', np.__version__, file=file)
    print('networkx    \t', nx.__version__, file=file)
    print('cvxpy      \t', cvx.__version__, file=file)
    print('pyquil      \t', pyquil.__version__, file=file)

    print(bk.name, '   \t', bk.version, '(BACKEND)', file=file) 
開發者ID:rigetti,項目名稱:quantumflow,代碼行數:22,代碼來源:meta.py

示例5: as_tree

# 需要導入模塊: import networkx [as 別名]
# 或者: from networkx import __version__ [as 別名]
def as_tree(graph, root=OPENSTACK_CLUSTER, reverse=False):
        if nx.__version__ >= '2.0':
            linked_graph = json_graph.node_link_graph(
                graph, attrs={'name': 'graph_index'})
        else:
            linked_graph = json_graph.node_link_graph(graph)
        if 0 == nx.number_of_nodes(linked_graph):
            return {}
        if reverse:
            linked_graph = linked_graph.reverse()
        if nx.__version__ >= '2.0':
            return json_graph.tree_data(
                linked_graph,
                root=root,
                attrs={'id': 'graph_index', 'children': 'children'})
        else:
            return json_graph.tree_data(linked_graph, root=root) 
開發者ID:openstack,項目名稱:vitrage,代碼行數:19,代碼來源:topology.py

示例6: trim

# 需要導入模塊: import networkx [as 別名]
# 或者: from networkx import __version__ [as 別名]
def trim(g, max_parents=False, max_children=False):
    if float(nx.__version__) < 2:
        edgedict = g.edge
    else:
        edgedict = g.adj
    for node in g:
        if max_parents:
            parents = list(g.successors(node))
            weights = [edgedict[node][parent]['weight'] for parent in parents]
            for weak_parent in np.argsort(weights)[:-max_parents]:
                g.remove_edge(node, parents[weak_parent])
        if max_children:
            children = g.predecessors(node)
            weights = [edgedict[child][node]['weight'] for child in children]
            for weak_child in np.argsort(weights)[:-max_children]:
                g.remove_edge(children[weak_child], node)
    return g 
開發者ID:gregversteeg,項目名稱:bio_corex,代碼行數:19,代碼來源:vis_corex.py

示例7: test_edge_id_construct

# 需要導入模塊: import networkx [as 別名]
# 或者: from networkx import __version__ [as 別名]
def test_edge_id_construct(self):
        G = nx.Graph()
        G.add_edges_from([(0, 1, {'id': 0}), (1, 2, {'id': 2}), (2, 3)])
        expected = """<gexf version="1.2" xmlns="http://www.gexf.net/1.2draft" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3.org/2001/XMLSchema-instance">
  <graph defaultedgetype="undirected" mode="static" name="">
    <meta>
      <creator>NetworkX {}</creator>
      <lastmodified>{}</lastmodified>
    </meta>
    <nodes>
      <node id="0" label="0" />
      <node id="1" label="1" />
      <node id="2" label="2" />
      <node id="3" label="3" />
    </nodes>
    <edges>
      <edge id="0" source="0" target="1" />
      <edge id="2" source="1" target="2" />
      <edge id="1" source="2" target="3" />
    </edges>
  </graph>
</gexf>""".format(nx.__version__, time.strftime('%d/%m/%Y'))
        obtained = '\n'.join(nx.generate_gexf(G))
        assert_equal(expected, obtained) 
開發者ID:holzschu,項目名稱:Carnets,代碼行數:26,代碼來源:test_gexf.py

示例8: check17_pillow

# 需要導入模塊: import networkx [as 別名]
# 或者: from networkx import __version__ [as 別名]
def check17_pillow(self):
        '''PILLOW
        Allows Production of jpg images from non-jpg images in LaTeX documents

        #TODO prculley mentions that : And PIL (Pillow) is also used by the
        main Gramps ([]narrativeweb and []other reports for image cropping)
        as well as [x]editexifmetadata and the
        new [x]latexdoc type addons (genealogytree).

        #TODO add check for PILLOW to "gramps -v"  section

        https://github.com/gramps-project/gramps/blob/maintenance/gramps50/gramps/plugins/docgen/latexdoc.py
        '''
        #self.append_text("\n")
        # Start check

        try:
            import PIL
            # from PIL import Image
            try:
                pil_ver = PIL.__version__
            except Exception:
                try:
                    pil_ver = str(PIL.PILLOW_VERSION)
                except Exception:
                    try:
                        #print(dir(PIL))
                        pil_ver = str(PIL.VERSION)
                    except Exception:
                        pil_ver = "Installed but does not supply version"
        except ImportError:
            pil_ver = "Not found"

        result = "(PILLOW " + pil_ver + ")"
        # End check
        self.append_text(result) 
開發者ID:gramps-project,項目名稱:addons-source,代碼行數:38,代碼來源:PrerequisitesCheckerGramplet.py

示例9: check_dependencies

# 需要導入模塊: import networkx [as 別名]
# 或者: from networkx import __version__ [as 別名]
def check_dependencies(self):
        try:
            import nose
            self.logger.debug("\tNose: %s\n" % str(nose.__version__))
        except ImportError:
            raise ImportError("Nose cannot be imported. Are you sure it's "
                              "installed?")
        try:
            import networkx
            self.logger.debug("\tnetworkx: %s\n" % str(networkx.__version__))
        except ImportError:
            raise ImportError("Networkx cannot be imported. Are you sure it's "
                              "installed?")
        try:
            import pymongo
            self.logger.debug("\tpymongo: %s\n" % str(pymongo.version))
            from bson.objectid import ObjectId
        except ImportError:
            raise ImportError("Pymongo cannot be imported. Are you sure it's"
                              " installed?")
        try:
            import numpy
            self.logger.debug("\tnumpy: %s" % str(numpy.__version__))
        except ImportError:
            raise ImportError("Numpy cannot be imported. Are you sure that it's"
                              " installed?")
        try:
            import scipy
            self.logger.debug("\tscipy: %s" % str(scipy.__version__))
        except ImportError:
            raise ImportError("Scipy cannot be imported. Are you sure that it's"
                              " installed?") 
開發者ID:automl,項目名稱:HPOlib,代碼行數:34,代碼來源:random_hyperopt_august2013_mod.py

示例10: node_iter

# 需要導入模塊: import networkx [as 別名]
# 或者: from networkx import __version__ [as 別名]
def node_iter(G):
    if float(nx.__version__)<2.0:
        return G.nodes()
    else:
        return G.nodes 
開發者ID:RexYing,項目名稱:diffpool,代碼行數:7,代碼來源:util.py

示例11: node_dict

# 需要導入模塊: import networkx [as 別名]
# 或者: from networkx import __version__ [as 別名]
def node_dict(G):
    if float(nx.__version__)>2.1:
        node_dict = G.nodes
    else:
        node_dict = G.node
    return node_dict
# --------------------------- 
開發者ID:RexYing,項目名稱:diffpool,代碼行數:9,代碼來源:util.py

示例12: get_graph

# 需要導入模塊: import networkx [as 別名]
# 或者: from networkx import __version__ [as 別名]
def get_graph(graph_type, depth, query, root, all_tenants):
        TopologyController._check_input_para(graph_type,
                                             depth,
                                             query,
                                             root,
                                             all_tenants)

        try:
            graph_data = pecan.request.client.call(pecan.request.context,
                                                   'get_topology',
                                                   graph_type=graph_type,
                                                   depth=depth,
                                                   query=query,
                                                   root=root,
                                                   all_tenants=all_tenants)
            graph = decompress_obj(graph_data)
            if graph_type == 'graph':
                return graph
            if graph_type == 'tree':
                if nx.__version__ >= '2.0':
                    node_id = ''
                    for node in graph['nodes']:
                        if (root and node[VProps.VITRAGE_ID] == root) or \
                                (not root and node[VProps.ID] == CLUSTER_ID):
                            node_id = node[VProps.GRAPH_INDEX]
                            break
                else:
                    node_id = CLUSTER_ID
                    if root:
                        for node in graph['nodes']:
                            if node[VProps.VITRAGE_ID] == root:
                                node_id = node[VProps.ID]
                                break
                return TopologyController.as_tree(graph, node_id)

        except Exception:
            LOG.exception('failed to get topology.')
            abort(404, 'Failed to get topology.') 
開發者ID:openstack,項目名稱:vitrage,代碼行數:40,代碼來源:topology.py

示例13: json_output_graph

# 需要導入模塊: import networkx [as 別名]
# 或者: from networkx import __version__ [as 別名]
def json_output_graph(self, **kwargs):
        """supports both 1.10<=networkx<2.0 and networx>=2.0 by returning the

        same json output regardless networx version

        :return: graph in json format
        """

        # TODO(annarez): when we decide to support networkx 2.0 with
        # versioning of Vitrage, we can move part of the logic to vitrageclient
        node_link_data = json_graph.node_link_data(self._g)
        node_link_data.update(kwargs)

        vitrage_id_to_index = dict()

        for index, node in enumerate(node_link_data['nodes']):
            vitrage_id_to_index[node[VProps.VITRAGE_ID]] = index
            if VProps.ID in self._g.nodes[node[VProps.ID]]:
                node[VProps.ID] = self._g.nodes[node[VProps.ID]][VProps.ID]
                node[VProps.GRAPH_INDEX] = index

        vers = nx.__version__
        if vers >= '2.0':
            for i in range(len(node_link_data['links'])):
                node_link_data['links'][i]['source'] = vitrage_id_to_index[
                    node_link_data['links'][i]['source']]
                node_link_data['links'][i]['target'] = vitrage_id_to_index[
                    node_link_data['links'][i]['target']]

        if kwargs.get('raw', False):
            return node_link_data
        else:
            return json.dumps(node_link_data) 
開發者ID:openstack,項目名稱:vitrage,代碼行數:35,代碼來源:networkx_graph.py

示例14: test_write_with_node_attributes

# 需要導入模塊: import networkx [as 別名]
# 或者: from networkx import __version__ [as 別名]
def test_write_with_node_attributes(self):
        # Addresses #673.
        G = nx.OrderedGraph()
        G.add_edges_from([(0, 1), (1, 2), (2, 3)])
        for i in range(4):
            G.nodes[i]['id'] = i
            G.nodes[i]['label'] = i
            G.nodes[i]['pid'] = i
            G.nodes[i]['start'] = i
            G.nodes[i]['end'] = i + 1

        expected = """<gexf version="1.2" xmlns="http://www.gexf.net/1.2draft" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3.org/2001/XMLSchema-instance">
  <graph defaultedgetype="undirected" mode="dynamic" name="" timeformat="long">
    <meta>
      <creator>NetworkX {}</creator>
      <lastmodified>{}</lastmodified>
    </meta>
    <nodes>
      <node end="1" id="0" label="0" pid="0" start="0" />
      <node end="2" id="1" label="1" pid="1" start="1" />
      <node end="3" id="2" label="2" pid="2" start="2" />
      <node end="4" id="3" label="3" pid="3" start="3" />
    </nodes>
    <edges>
      <edge id="0" source="0" target="1" />
      <edge id="1" source="1" target="2" />
      <edge id="2" source="2" target="3" />
    </edges>
  </graph>
</gexf>""".format(nx.__version__, time.strftime('%d/%m/%Y'))
        obtained = '\n'.join(nx.generate_gexf(G))
        assert_equal(expected, obtained) 
開發者ID:holzschu,項目名稱:Carnets,代碼行數:34,代碼來源:test_gexf.py

示例15: add_meta

# 需要導入模塊: import networkx [as 別名]
# 或者: from networkx import __version__ [as 別名]
def add_meta(self, G, graph_element):
        # add meta element with creator and date
        meta_element = Element('meta')
        SubElement(meta_element, 'creator').text = 'NetworkX {}'.format(nx.__version__)
        SubElement(meta_element, 'lastmodified').text = time.strftime('%d/%m/%Y')
        graph_element.append(meta_element) 
開發者ID:holzschu,項目名稱:Carnets,代碼行數:8,代碼來源:gexf.py


注:本文中的networkx.__version__方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。