test_match v0.1.0 TestMatch.Lib

Module for reading and writing a library of libgraph graphs.

The read_graph/1 and write_graph/2 functions allow for reading and writing RDF graphs to the project data repository. (Default file names are provided with the read_graph/0 and write_graph/1 forms.) The list_graphs/0 function lists graph file names.

Some simple accessor functions are also available:

Link to this section Summary

Functions

Create @node_table and @edge_table ETS tables.

Returns a default Cypher query.

Executes cypher_query and returns a graph.

Executes cypher_query and returns a graph with properties in ETS tables.

Executes sparql_query and returns a graph.

Returns a default Lib graph file.

Returns the Lib graphs directory.

Lists Lib graphs in the Lib graph images library.

Lists Lib graphs in the Lib graphs library.

Reads a Lib graph from the Lib graphs library.

Returns a default SPARQL query.

Returns a temp Lib graph file for writing.

Writes a graph to a .png file in the Lib graph images library.

Writes a Lib graph to a file in the Lib graphs library.

Writes a Lib graph to a file in the Lib graphs library.

Link to this section Functions

Link to this function

create_ets_tables()

Create @node_table and @edge_table ETS tables.

Returns a default Cypher query.

Link to this function

from_cypher(cypher_query \\ cypher_query())

Executes cypher_query and returns a graph.

Link to this function

from_cypher_with_properties(cypher_query \\ cypher_query())

Executes cypher_query and returns a graph with properties in ETS tables.

Link to this function

from_sparql(sparql_query \\ sparql_query())

Executes sparql_query and returns a graph.

Returns a default Lib graph file.

Examples

iex> TestMatch.Lib.graph_file()
"default.ttl"

Returns the Lib graphs directory.

Link to this function

list_graph_images()

Lists Lib graphs in the Lib graph images library.

Examples

iex> list_graph_images()
["tony.png", "foo.png", "foo1.png"]

Lists Lib graphs in the Lib graphs library.

Examples

iex> list_graphs()
["tony.dot", "foo.dot", "foo1.dot"]
Link to this function

read_graph(graph_file \\ graph_file())

Reads a Lib graph from the Lib graphs library.

Examples

iex> read_graph()
%TestMatch.Graph{
  data: "<http://dbpedia.org/resource/Hello_World>\n..."
  file: "default.ttl",
  path: ".../test_graph/priv/rdf/graphs/default.ttl",
  type: :rdf,
  uri: "file:///.../test_graph/priv/rdf/graphs/default.ttl"
}

iex> read_graph("books.ttl")
%TestMatch.Graph{
  data: "@prefix bibo: <http://purl.org/ontology/bibo/> \n..."
  file: "books.ttl",
  path: ".../test_graph/priv/rdf/graphs/books.ttl",
  type: :rdf,
  uri: "file:///.../test_graph/priv/rdf/graphs/books.ttl"
}

Returns a default SPARQL query.

Link to this function

temp_graph_file()

Returns a temp Lib graph file for writing.

Examples

iex> TestMatch.Lib.temp_graph_file()
"temp.ttl"
Link to this function

to_png(graph, binary \\ :dot)

Writes a graph to a .png file in the Lib graph images library.

The layout tool used is selected by the binary argument and is one of the following atoms:

  • :dot − filter for drawing directed graphs
  • :neato − filter for drawing undirected graphs
  • :twopi − filter for radial layouts of graphs
  • :circo − filter for circular layout of graphs
  • :fdp − filter for drawing undirected graphs
  • :sfdp − filter for drawing large undirected graphs
  • :patchwork − filter for squarified tree maps
  • :osage − filter for array-based layouts
Link to this function

write_graph(graph_data, graph_file \\ temp_graph_file())

Writes a Lib graph to a file in the Lib graphs library.

Examples

iex> data |> write_graph("my.dot")
%TestMatch.Graph{
  data: "@prefix bibo: <http://purl.org/ontology/bibo/> \n..."
  file: "my.dot",
  path: "/test_graph/priv/lib/graphs/my.dot",
  type: :lib,
  uri: "file:///.../test_graph/priv/lib/graphs/my.dot"
}
Link to this function

write_lib_graph(lib_graph, graph_file \\ temp_graph_file())

Writes a Lib graph to a file in the Lib graphs library.