Skip to content

DAMA-UPC/Babel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

aa0f84b · Oct 25, 2018
Oct 16, 2018
Oct 25, 2018
Aug 2, 2017
May 20, 2018
Oct 25, 2018
Jun 4, 2018
Jul 26, 2017
May 20, 2018
Oct 25, 2018
Oct 25, 2018
May 20, 2018
Oct 25, 2018

Repository files navigation

Babel: A domain specific language for graph generation

Build Status Codacy Badge Codacy Badge

running-example

Add dependency:

https://bintray.com/dama-upc/Babel-Platform/babel

If using the SBT tool:

Add the following snippet to the build.sbt file:

resolvers += "maven" at "https://dl.bintray.com/dama-upc/Babel-Platform"
libraryDependencies += "edu.upc.dama" %% "babel" % "0.4.1"
addCompilerPlugin("org.scalameta" % "paradise" % "3.0.0-M11" cross CrossVersion.full)

Definition of node models

import babel._
import java.time.LocalDate

@node class Actor(name: String,
                  gender: Option[String],
                  country: String,
                  birthDate: LocalDate)
import babel._

@node class Movie(director: String,
                  title: String,
                  releaseDate: LocalDate,
                  country: String,
                  budgetInUSDollars: Option[Double])

Definition of Edge models

import babel._
import java.time.LocalDate

@edge
class Portrayed(characterName: String)

### Property generators definition

import babel._

object ActorBirthDateGenerator extends PropertyGenerator[LocalDate] {

  override def run(id: Id,
                   r: (Id) => Long,
                   dependencies: Any*): LocalDate =
    LocalDateGenerator.nextLocalDate(
      hash = r(id),
      min = NOW().minusYears(90),
      max = NOW(),
      distribution = Distribution.Uniform
    )
}

Defining graph structure generators.

For defining graph structure generators, we need to implement the following interface:

trait GraphStructureGenerator[T] {
  val run(n: Long): T
  val getNumberNodes(numberEdges: Long): Long
}