Creates the nodes and directed edges of the dependency graph.

    Args:
      os_name: String specifying the OS name.
      artifact_list: List of requested artifact names.
320977
def _InitializeGraph(self, os_name, artifact_list):
    
    dependencies = artifact_registry.REGISTRY.SearchDependencies(
        os_name, artifact_list)
    artifact_names, attribute_names = dependencies

    self._AddAttributeNodes(attribute_names)
    self._AddArtifactNodesAndEdges(artifact_names)
288506
def get_required_dists(dists, dist):
    
    if dist not in dists:
        raise DistlibException('given distribution %r is not a member '
                               'of the list' % dist.name)
    graph = make_graph(dists)

    req = []  # required distributions
    todo = graph.adjacency_list[dist]  # list of nodes we should inspect

    while todo:
        d = todo.pop()[0]
        req.append(d)
        for pred in graph.adjacency_list[d]:
            if pred not in req:
                todo.append(pred)

    return req
50522
def dependencies_of(names)
      names = Array === names ? names.dup : names.to_a
      assert_strings!(names)

      deps = Set.new
      until names.empty?
        name = names.shift
        next if deps.include?(name)

        deps << name
        names.concat index[name].dependencies.map(&:name)
      end
      deps.to_a
    end
470527
def deps_tree(self):
        
        dependencies = self.dependencies + [self.name]
        if self.repo == "sbo":
            for dep in dependencies:
                deps = Requires(flag="").sbo(dep)
                if dep not in self.deps_dict.values():
                    self.deps_dict[dep] = Utils().dimensional_list(deps)
        else:
            for dep in dependencies:
                deps = Dependencies(self.repo, self.black).binary(dep, flag="")
                if dep not in self.deps_dict.values():
                    self.deps_dict[dep] = Utils().dimensional_list(deps)
375354
def getGraphFieldList(self, graph_name):
        
        graph = self._getGraph(graph_name, True)
        return graph.getFieldList()
511127
private void resolveDependenciesInParallel(List<DependencyNode> nodes) {
        List<ArtifactRequest> artifactRequests = nodes.stream()
                .map(node -> new ArtifactRequest(node.getArtifact(), this.remoteRepositories, null))
                .collect(Collectors.toList());

        try {
            this.resolver.resolveArtifacts(this.session, artifactRequests);
        } catch (ArtifactResolutionException e) {
            // ignore, error will be printed by resolve(ArtifactSpec)
        }
    }
1069218
def aliasByNode(requestContext, seriesList, *nodes):
    
    for series in seriesList:
        pathExpression = _getFirstPathExpression(series.name)
        metric_pieces = pathExpression.split('.')
        series.name = '.'.join(metric_pieces[n] for n in nodes)
    return seriesList
808254
def _addrs2nodes(addrs, G):
    
    for i, n in enumerate(G.nodes()):
        G.node[n]['addr'] = addrs[i]
178251
public static Set<Artifact> getArtifactsToConsider(AbstractWisdomMojo mojo, DependencyGraphBuilder graph,
                                                       boolean transitive, ArtifactFilter filter) {
        // No transitive.
        Set<Artifact> artifacts;
        if (!transitive) {
            // Direct dependencies that the current project has (no transitives)
            artifacts = mojo.project.getDependencyArtifacts();
        } else {
            // All dependencies that the current project has, including transitive ones. Contents are lazily
            // populated, so depending on what phases have run dependencies in some scopes won't be
            // included.
            artifacts = getTransitiveDependencies(mojo, graph, filter);
        }
        return artifacts;
    }
98367
def add_node(self, node_name):
        
        graph = self.graph
        if node_name in graph:
            raise KeyError('node %s already exists' % node_name)
        graph[node_name] = set()
779480
def create_build_graph(self, target_roots, build_root=None):
    
    logger.debug('target_roots are: %r', target_roots)
    graph = LegacyBuildGraph.create(self.scheduler_session, self.build_file_aliases)
    logger.debug('build_graph is: %s', graph)
    # Ensure the entire generator is unrolled.
    for _ in graph.inject_roots_closure(target_roots):
      pass

    address_mapper = LegacyAddressMapper(self.scheduler_session, build_root or get_buildroot())
    logger.debug('address_mapper is: %s', address_mapper)
    return graph, address_mapper
931957
def graph_repo(repo_url, output_loc, format='graphml'):  
  
  log = logging.getLogger("graphgit")
  # repo type
  local_repo = os.path.isabs(repo_url)
  # repo name
  repo_name = repo_url[repo_url.rfind('/')+1:repo_url.rfind('.git')] \
    if not local_repo else repo_url[repo_url.rfind(os.sep)+1:]
  log.info ("Processing git repository: %s" % repo_name)
  # repo location
  repo_loc = os.path.join(constants.REPO_DOWNLOAD_LOCATION, repo_name) \
    if not local_repo else repo_url
  # initialize repo
  repo = None
  gitt = git.Git()
  try:
    # check if repo is already cloned
    # if local repo exists, assign
    repo = git.Repo(repo_loc, odbt=git.GitCmdObjectDB)    
    log.info( "Repository already cloned... Going ahead and using it..." )
    # TODO: check if repo is dirty and if so, update
  except git.exc.NoSuchPathError:
    # local repo doesn't exist. clone
    try:
      if local_repo:
        raise Exception
      log.info( "Cloning repository... this might take some time, please wait !" )
      gitt.clone(repo_url, repo_loc)
      log.info( "Git clone completed..." )  
      repo = git.Repo(repo_loc, odbt=git.GitCmdObjectDB)
    except:
      log.error( "Could not obtain repository: %s !" % repo_url )
      sys.exit(1)
    
  if repo is None:
    log.error( "Could not obtain repository: %s !" % repo_url )
    sys.exit(1)

  # create a graph for the repo
  G = nx.DiGraph()
  # root node
  G.add_node(repo_name, type=constants.NODE_TYPE_VALS['REPOSITORY'])
  # branches & commits
  for branch in repo.branches:
    log.debug ("Processing branch %s" % branch)
    G.add_node(branch, type=constants.NODE_TYPE_VALS['BRANCH'])
    G.add_edge(repo_name, branch, 
      label=constants.EDGE_LABEL_VALS['REPOSITORY_BRANCH'])
    for commit in repo.iter_commits(branch):
      try:
        author = safe_str(commit.author)
        ts = commit.committed_date
        sha = safe_str(commit)
        log.debug ("%s> %s --[commit]--> %s" % (branch, author, sha))
        G.add_node(author, type=constants.NODE_TYPE_VALS['PERSON'])
        G.add_node(sha, ts=ts,
          type=constants.NODE_TYPE_VALS['COMMIT'])
        G.add_edge(author, sha, 
          label=constants.EDGE_LABEL_VALS['PERSON_COMMIT'])
        G.add_edge(branch, sha, 
          label=constants.EDGE_LABEL_VALS['BRANCH_COMMIT'])
      except LookupError:
        log.warning('Could not process %s !' % commit)      
        continue

  log.info( "Graph built ! saving..." )

  # save graph
  output_file_name = '%s.%s' % (repo_name, format)
  output_file_loc = os.path.join(output_loc, output_file_name)
  if format == 'graphml':
    nx.write_graphml(G, output_file_loc, encoding='utf-8')
  elif format == 'gexf':
    nx.write_gexf(G, output_file_loc, encoding='utf-8')
  else:
    log.error( "Invalid output format: %s !" % format )
    sys.exit(1)

  log.info( "Saved to %s !" % output_file_loc )
339140
def init_supervisor_data(dotfile, sample_sets):
    
    with open(dotfile) as wf:
        graph_data = wf.read()

    graph = pydot.graph_from_dot_data(graph_data)[0]
    nodes = [n.get_name().strip('"') for n in graph.get_nodes()]

    monitor_data = dict()
    dependencies = {n:[] for n in nodes}

    # Initialize empty list of dependencies
    for n in nodes:
        monitor_data[n] = dict()
        for sset in sample_sets:
            monitor_data[n][sset] = {
                'state'        : "Not Started",
                'evaluated'    : False,
                'succeeded'    : False
            }

    edges = graph.get_edges()

    # Iterate over the edges, and get the dependency information for each node
    for e in edges:
        source = e.get_source().strip('"')
        dest = e.get_destination().strip('"')

        dep = e.get_attributes()
        dep['upstream_task'] = source

        dependencies[dest].append(dep)

    return monitor_data, dependencies
205047
def Artifacts(self, os_name=None, cpe=None, label=None):
    
    hit = lambda x: x[0] == x[1] or not x[0]
    seq = [(self.os_name, os_name), (self.cpe, cpe), (self.label, label)]
    return all(map(hit, seq))
318940
def make_example_graphs():
    ""
    cag_example_rdfs = {}
    for i, fname in enumerate(os.listdir('cag_examples')):
        cag_example_rdfs[i+1] = get_example_extractions(fname)
    return make_cag_graphs(cag_example_rdfs)
453904
def get_subgraphs(graph=None):
    
    graph = graph or DEPENDENCIES
    keys = set(graph)
    frontier = set()
    seen = set()
    while keys:
        frontier.add(keys.pop())
        while frontier:
            component = frontier.pop()
            seen.add(component)
            frontier |= set([d for d in get_dependencies(component) if d in graph])
            frontier |= set([d for d in get_dependents(component) if d in graph])
            frontier -= seen
        yield dict((s, get_dependencies(s)) for s in seen)
        keys -= seen
        seen.clear()
950545
def get_dependency_graph(component):
    
    if component not in DEPENDENCIES:
        raise Exception("%s is not a registered component." % get_name(component))

    if not DEPENDENCIES[component]:
        return {component: set()}

    graph = defaultdict(set)

    def visitor(c, parent):
        if parent is not None:
            graph[parent].add(c)

    walk_dependencies(component, visitor)

    graph = dict(graph)

    # Find all items that don't depend on anything.
    extra_items_in_deps = _reduce(set.union, graph.values(), set()) - set(graph.keys())

    # Add empty dependencies where needed.
    graph.update(dict((item, set()) for item in extra_items_in_deps))

    return graph