Print the given {@link ProjectModel} as Graphviz .dot file to the given
file
17467
public void print(ProjectModel project, File f, boolean includeClasses)
			throws IOException {
		FileWriter writer = new FileWriter(f);
		print(project, writer, includeClasses);
		writer.close();
	}
719434
public static ProjectModel getProjectModel() {
		synchronized (Modules.class) {
			if (Modules.projectModel == null) {
				ClassLoader classLoader = Modules.class.getClassLoader();
				Config config = new Config(new Properties());
				try (InputStream in = classLoader
						.getResourceAsStream("jabsaw.properties")) {
					Properties properties = new Properties();
					if (in != null) {
						properties.load(in);
					} else {
						Modules.logger.info("jabsaw.properties not found");
					}
					config = new Config(properties);
					Modules.logger.info("loaded jabsaw.properties");
				} catch (IOException e1) {
					Modules.logger.error("error loading jabsaw.properties");
				}

				try {
					// load all classes on the classpath
					ImmutableList<ClassInfo> classes = FluentIterable
							.from(ClassPath.from(classLoader).getResources())
							.filter(ClassInfo.class).toList();
					ClassParser parser = new ClassParser();
					parser.getProject()
							.setUseModuleNames(config.useModuleNames);
					for (ClassInfo info : classes) {
						if (!config.includeJars) {
							if ("jar".equals(info.url().getProtocol())) {
								continue;
							}
						}
						if (config.excludePath != null
								&& info.url().getPath()
										.contains(config.excludePath)) {
							continue;
						}
						Modules.logger.trace("parsing" + info.url());

						try (InputStream is = classLoader
								.getResourceAsStream(info.getResourceName())) {
							ClassReader reader = new ClassReader(is);
							parser.parse(reader);
						} catch (Throwable t) {
							Modules.logger.error(
									"Error while reading " + info.getName(), t);
						}
					}
					parser.getProject().resolveDependencies();
					Modules.projectModel = parser.getProject();
				} catch (IOException e) {
					throw new RuntimeException(
							"error while reading classes on classpath", e);
				}
			}
		}
		return Modules.projectModel;
	}
290784
def do_graphviz(self, args, arguments):
        
        filename = arguments['FILENAME']
        if platform.system() == 'Darwin':
            if os.path.isfile(filename):
                os.system("open -a '\''/Applications/Graphviz.app'\'' " + filename)
260112
def build_modelgraph(docs_path, package_name="yacms"):
    
    to_path = os.path.join(docs_path, "img", "graph.png")
    build_path = os.path.join(docs_path, "build", "_images")
    resized_path = os.path.join(os.path.dirname(to_path), "graph-small.png")
    settings = import_dotted_path(package_name +
                                  ".project_template.project_name.settings")
    apps = [a.rsplit(".")[1] for a in settings.INSTALLED_APPS
            if a.startswith("yacms.") or a.startswith(package_name + ".")]
    try:
        from django_extensions.management.commands import graph_models
    except ImportError:
        warn("Couldn't build model_graph, django_extensions not installed")
    else:
        options = {"inheritance": True, "outputfile": "graph.png",
                   "layout": "dot"}
        try:
            graph_models.Command().execute(*apps, **options)
        except Exception as e:
            warn("Couldn't build model_graph, graph_models failed on: %s" % e)
        else:
            try:
                move("graph.png", to_path)
            except OSError as e:
                warn("Couldn't build model_graph, move failed on: %s" % e)
    # docs/img/graph.png should exist in the repo - move it to the build path.
    try:
        if not os.path.exists(build_path):
            os.makedirs(build_path)
        copyfile(to_path, os.path.join(build_path, "graph.png"))
    except OSError as e:
        warn("Couldn't build model_graph, copy to build failed on: %s" % e)
    try:
        from PIL import Image
        image = Image.open(to_path)
        image.width = 800
        image.height = image.size[1] * 800 // image.size[0]
        image.save(resized_path, "PNG", quality=100)
    except Exception as e:
        warn("Couldn't build model_graph, resize failed on: %s" % e)
        return
    # Copy the dashboard screenshot to the build dir too. This doesn't
    # really belong anywhere, so we do it here since this is the only
    # spot we deal with doc images.
    d = "dashboard.png"
    copyfile(os.path.join(docs_path, "img", d), os.path.join(build_path, d))
591583
public Iterable<InlineHintModel> getHintsForFile(FileModel file)
    {
        GraphTraversal<Vertex, Vertex> inlineHintPipeline = new GraphTraversalSource(getGraphContext().getGraph()).V(file.getElement());
        inlineHintPipeline.in(FileReferenceModel.FILE_MODEL);
        inlineHintPipeline.has(WindupVertexFrame.TYPE_PROP, Text.textContains(InlineHintModel.TYPE));
        return new FramedVertexIterable<>(getGraphContext().getFramed(), inlineHintPipeline.toList(), InlineHintModel.class);
    }
80527
def dotty (params = {})
      dotfile = "graph.dot"
      File.open(dotfile, "w") {|f|
        print_dotted_on(params, f)
      }
      system("dotty", dotfile)
    end
210307
private static void listProjectProperties(ProjectFile file)
   {
      SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy HH:mm z");
      ProjectProperties properties = file.getProjectProperties();
      Date startDate = properties.getStartDate();
      Date finishDate = properties.getFinishDate();
      String formattedStartDate = startDate == null ? "(none)" : df.format(startDate);
      String formattedFinishDate = finishDate == null ? "(none)" : df.format(finishDate);

      System.out.println("MPP file type: " + properties.getMppFileType());
      System.out.println("Project Properties: StartDate=" + formattedStartDate + " FinishDate=" + formattedFinishDate);
      System.out.println();
   }
832679
private void processProject(PrimaveraDatabaseReader reader, int projectID, String outputFile) throws Exception
   {
      long start = System.currentTimeMillis();
      reader.setProjectID(projectID);
      ProjectFile projectFile = reader.read();
      long elapsed = System.currentTimeMillis() - start;
      System.out.println("Reading database completed in " + elapsed + "ms.");

      System.out.println("Writing output file started.");
      start = System.currentTimeMillis();
      ProjectWriter writer = ProjectWriterUtility.getProjectWriter(outputFile);
      writer.write(projectFile, outputFile);
      elapsed = System.currentTimeMillis() - start;
      System.out.println("Writing output completed in " + elapsed + "ms.");
   }
927519
def render_dot(self, code, options, format, prefix='graphviz'):
    # type: (nodes.NodeVisitor, unicode, Dict, unicode, unicode) -> Tuple[unicode, unicode]
    """"""
    graphviz_dot = options.get('graphviz_dot', self.builder.config.graphviz_dot)
    hashkey = (code + str(options) + str(graphviz_dot) +
               str(self.builder.config.graphviz_dot_args)).encode('utf-8')

    fname = '%s-%s.%s' % (prefix, sha1(hashkey).hexdigest(), format)
    relfn = posixpath.join(self.builder.imgpath, fname)
    outfn = path.join(self.builder.outdir, self.builder.imagedir, fname)

    if path.isfile(outfn):
        return relfn, outfn

    if (hasattr(self.builder, '_graphviz_warned_dot') and
       self.builder._graphviz_warned_dot.get(graphviz_dot)):
        return None, None

    ensuredir(path.dirname(outfn))

    # graphviz expects UTF-8 by default
    if isinstance(code, text_type):
        code = code.encode('utf-8')

    dot_args = [graphviz_dot]
    dot_args.extend(self.builder.config.graphviz_dot_args)
    dot_args.extend(['-T' + format, '-o' + outfn])
    if format == 'png':
        dot_args.extend(['-Tcmapx', '-o%s.map' % outfn])
    try:
        p = Popen(dot_args, stdout=PIPE, stdin=PIPE, stderr=PIPE)
    except OSError as err:
        if err.errno != ENOENT:   # No such file or directory
            raise
        logger.warning(__('dot command %r cannot be run (needed for graphviz '
                          'output), check the graphviz_dot setting'), graphviz_dot)
        if not hasattr(self.builder, '_graphviz_warned_dot'):
            self.builder._graphviz_warned_dot = {}
        self.builder._graphviz_warned_dot[graphviz_dot] = True
        return None, None
    try:
        # Graphviz may close standard input when an error occurs,
        # resulting in a broken pipe on communicate()
        stdout, stderr = p.communicate(code)
    except (OSError, IOError) as err:
        if err.errno not in (EPIPE, EINVAL):
            raise
        # in this case, read the standard output and standard error streams
        # directly, to get the error message(s)
        stdout, stderr = p.stdout.read(), p.stderr.read()
        p.wait()
    if p.returncode != 0:
        raise GraphvizError(__('dot exited with error:\n[stderr]\n%s\n'
                               '[stdout]\n%s') % (stderr, stdout))
    if not path.isfile(outfn):
        raise GraphvizError(__('dot did not produce an output file:\n[stderr]\n%s\n'
                               '[stdout]\n%s') % (stderr, stdout))
    return relfn, outfn
208171
private void writeProjectProperties(ProjectProperties record) throws IOException
   {
      // the ProjectProperties class from MPXJ has the details of how many days per week etc....
      // so I've assigned these variables in here, but actually use them in other methods
      // see the write task method, that's where they're used, but that method only has a Task object
      m_minutesPerDay = record.getMinutesPerDay().doubleValue();
      m_minutesPerWeek = record.getMinutesPerWeek().doubleValue();
      m_daysPerMonth = record.getDaysPerMonth().doubleValue();

      // reset buffer to be empty, then concatenate data as required by USACE
      m_buffer.setLength(0);
      m_buffer.append("PROJ ");
      m_buffer.append(m_formatter.format(record.getStartDate()).toUpperCase() + " "); // DataDate
      m_buffer.append(SDEFmethods.lset(record.getManager(), 4) + " "); // ProjIdent
      m_buffer.append(SDEFmethods.lset(record.getProjectTitle(), 48) + " "); // ProjName
      m_buffer.append(SDEFmethods.lset(record.getSubject(), 36) + " "); // ContrName
      m_buffer.append("P "); // ArrowP
      m_buffer.append(SDEFmethods.lset(record.getKeywords(), 7)); // ContractNum
      m_buffer.append(m_formatter.format(record.getStartDate()).toUpperCase() + " "); // ProjStart
      m_buffer.append(m_formatter.format(record.getFinishDate()).toUpperCase()); // ProjEnd
      m_writer.println(m_buffer);
   }
885316
public SourceReportModel getSourceReportForFileModel(FileModel fileModel)
    {
        GraphTraversal<Vertex, Vertex> pipeline = new GraphTraversalSource(getGraphContext().getGraph()).V(fileModel.getElement());
        pipeline.in(SourceReportModel.SOURCE_REPORT_TO_SOURCE_FILE_MODEL);

        SourceReportModel result = null;
        if (pipeline.hasNext())
        {
            result = frame(pipeline.next());
        }
        return result;
    }
1091885
private ProjectFile readProjectFile(ProjectReader reader, InputStream stream) throws MPXJException
   {
      addListeners(reader);
      return reader.read(stream);
   }
1182076
private static <N, E> void writeRaw(Graph<N, E> graph,
                                        Appendable a,
                                        DOTVisualizationHelper<N, ? super E> dotHelperOrNull) throws IOException {

        final DOTVisualizationHelper<N, ? super E> dotHelper;

        if (dotHelperOrNull == null) {
            dotHelper = new DefaultDOTVisualizationHelper<>();
        } else {
            dotHelper = dotHelperOrNull;
        }

        final boolean directed = !(graph instanceof UndirectedGraph);

        if (directed) {
            a.append("di");
        }

        a.append("graph g {").append(System.lineSeparator());

        Map<String, String> props = new HashMap<>();

        dotHelper.getGlobalNodeProperties(props);
        if (!props.isEmpty()) {
            a.append('\t').append("node");
            appendParams(props, a);
            a.append(';').append(System.lineSeparator());
        }

        props.clear();
        dotHelper.getGlobalEdgeProperties(props);
        if (!props.isEmpty()) {
            a.append('\t').append("edge");
            appendParams(props, a);
            a.append(';').append(System.lineSeparator());
        }

        dotHelper.writePreamble(a);
        a.append(System.lineSeparator());

        MutableMapping<N, String> nodeNames = graph.createStaticNodeMapping();
        Set<String> initialNodes = new HashSet<>();

        int i = 0;

        for (N node : graph) {
            props.clear();
            if (!dotHelper.getNodeProperties(node, props)) {
                continue;
            }
            String id = "s" + i++;

            // remove potential attributes that are no valid DOT attributes
            if (Boolean.parseBoolean(props.remove(NodeAttrs.INITIAL))) {
                initialNodes.add(id);
            }
            props.remove(NodeAttrs.ACCEPTING);

            a.append('\t').append(id);
            appendParams(props, a);
            a.append(';').append(System.lineSeparator());
            nodeNames.put(node, id);
        }

        for (N node : graph) {
            String srcId = nodeNames.get(node);
            if (srcId == null) {
                continue;
            }
            Collection<E> outEdges = graph.getOutgoingEdges(node);
            if (outEdges.isEmpty()) {
                continue;
            }
            for (E e : outEdges) {
                N tgt = graph.getTarget(e);
                String tgtId = nodeNames.get(tgt);
                if (tgtId == null) {
                    continue;
                }

                if (!directed && tgtId.compareTo(srcId) < 0) {
                    continue;
                }

                props.clear();
                if (!dotHelper.getEdgeProperties(node, e, tgt, props)) {
                    continue;
                }

                a.append('\t').append(srcId).append(' ');
                if (directed) {
                    a.append("-> ");
                } else {
                    a.append("-- ");
                }
                a.append(tgtId);
                appendParams(props, a);
                a.append(';').append(System.lineSeparator());
            }
        }

        a.append(System.lineSeparator());
        renderInitialArrowTip(initialNodes, a);

        dotHelper.writePostamble(a);
        a.append(System.lineSeparator());

        a.append('}').append(System.lineSeparator());
        if (a instanceof Flushable) {
            ((Flushable) a).flush();
        }
    }
108379
public static String toDot(GraphvizGraph graph) {
    StringBuilder builder = new StringBuilder();
    builder.append(graph.isDirected() ? "digraph" : "graph");
    builder.append(INDENT);
    builder.append(graph.getName());
    builder.append(" {\n");
    builder.append(INDENT);
    builder.append("node [color=lightblue2, style=filled];\n");

    final String edgeSymbol = graph.isDirected() ? ARROW : LINE;

    List<GraphvizNode> nodes = graph.getGraphvizNodes();

    String[] nodeNames = new String[nodes.size()];

    for (int i = 0; i < nodeNames.length; i++) {
      GraphvizNode gNode = nodes.get(i);
      nodeNames[i] =
          gNode.getId()
              + " [label=\""
              + gNode.getLabel()
              + "\" color=\""
              + gNode.getColor()
              + "\"]";
    }

    // We sort the nodes so we get a deterministic output every time regardless
    // of the implementation of the graph data structure.
    Arrays.sort(nodeNames);

    for (String nodeName : nodeNames) {
      builder.append(INDENT);
      builder.append(nodeName);
      builder.append(";\n");
    }

    List<GraphvizEdge> edges = graph.getGraphvizEdges();

    String[] edgeNames = new String[edges.size()];

    for (int i = 0; i < edgeNames.length; i++) {
      GraphvizEdge edge = edges.get(i);
      edgeNames[i] = edge.getNode1Id() + edgeSymbol + edge.getNode2Id();
    }

    // Again, we sort the edges as well.
    Arrays.sort(edgeNames);

    for (String edgeName : edgeNames) {
      builder.append(INDENT);
      builder.append(edgeName);
      builder.append(";\n");
    }

    builder.append("}\n");
    return builder.toString();
  }
753004
static String toDot(Node n, ControlFlowGraph<Node> inCFG)
      throws IOException  {
    StringBuilder builder = new StringBuilder();
    new DotFormatter(n, inCFG, builder, false);
    return builder.toString();
  }
450558
@VisibleForTesting
  @GwtIncompatible("Unnecessary")
  void printModuleGraphJsonTo(Appendable out) throws IOException {
    out.append(compiler.getModuleGraph().toJson().toString());
  }
328759
@GwtIncompatible("Unnecessary")
  private void outputModuleGraphJson() throws IOException {
    if (config.outputModuleDependencies != null &&
        config.outputModuleDependencies.length() != 0) {
      try (Writer out = fileNameToOutputWriter2(config.outputModuleDependencies)) {
        printModuleGraphJsonTo(out);
      }
    }
  }