com.linkedin.dagli.visualization.ascii.AsciiVisualization Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of visualization-ascii Show documentation
Show all versions of visualization-ascii Show documentation
DAG-oriented machine learning framework for bug-resistant, readable, efficient, maintainable and trivially deployable models in Java and other JVM languages
package com.linkedin.dagli.visualization.ascii;
import com.github.mdr.ascii.layout.Graph;
import com.github.mdr.ascii.layout.Layouter;
import com.linkedin.dagli.producer.Producer;
import com.linkedin.dagli.util.collection.LazyMap;
import com.linkedin.dagli.visualization.AbstractVisualization;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import scala.Tuple2;
import scala.collection.JavaConversions;
/**
* Renders Dagli DAGs via ASCII art rendering.
*/
public class AsciiVisualization extends AbstractVisualization {
/**
* Simple Vertex class that stores a string value "by reference" (rather than using value equality semantics).
*/
private static class Vertex {
final String _text;
private Vertex(String text) {
_text = text;
}
@Override
public String toString() {
return _text;
}
}
/**
* Given a {@link Graph} (such as that from a DAG class, e.g. DAG1x1), returns a String containing a visualization of
* that graph as ASCII art. Please note that this ASCII art may be arbitrarily wide and may not render correctly
* if soft wrapping is employed when displaying it.
*
* @param graph a graph (such as a DAG) to render
* @param producerOutputs a list of examples, expressed as a map of outputs for each producer, to render
* @return the graph rendered as ASCII art
*/
@Override
@SuppressWarnings({"unchecked", "rawtypes"})
protected String render(com.linkedin.dagli.dag.Graph> graph,
List
© 2015 - 2024 Weber Informatics LLC | Privacy Policy