{"id":22116334,"url":"https://github.com/jmid/ocaml-skyline","last_synced_at":"2025-03-24T05:41:27.298Z","repository":{"id":19538257,"uuid":"22786174","full_name":"jmid/ocaml-skyline","owner":"jmid","description":"An OCaml implementation of the Skyline problem","archived":false,"fork":false,"pushed_at":"2014-08-09T12:59:13.000Z","size":108,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-29T11:27:31.462Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"OCaml","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jmid.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-08-09T12:56:49.000Z","updated_at":"2014-08-09T12:59:13.000Z","dependencies_parsed_at":"2022-08-24T03:30:58.525Z","dependency_job_id":null,"html_url":"https://github.com/jmid/ocaml-skyline","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmid%2Focaml-skyline","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmid%2Focaml-skyline/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmid%2Focaml-skyline/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmid%2Focaml-skyline/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jmid","download_url":"https://codeload.github.com/jmid/ocaml-skyline/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245217791,"owners_count":20579297,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-01T12:27:05.275Z","updated_at":"2025-03-24T05:41:27.258Z","avatar_url":"https://github.com/jmid.png","language":"OCaml","funding_links":[],"categories":[],"sub_categories":[],"readme":"Skyline solver\n==============\n\nThis is a divide-and-conquer implementation of the Skyline problem.\nIt is structured into two modules: one for solving the problem proper\nand one for generating random input cities, invoking the solver, and\nemitting output for gnuplot.\n\n\nWe represent both cities and skylines as lists:\n- A city is represented as a (xvalue,house_height,house_length) list.\n- A skyline is represented as a (xvalue,height) list.\n\n\nTo compute skylines recursively, we split the input city in two, and\nmerge the resulting skylines.\n\nTo merge two skylines, we\n - overlay one skyline over another, recording the height of each \"interesting\" x-point,\n - compute the maximum height for each such x-point, and\n - finally clean up the list.\n\nThis can be expressed concisely as:\n\n    (*  skyline : (int * int * int) list -\u003e (int * int) list  *)\n    let rec skyline l = match l with\n      | []        -\u003e []\n      | [(x,h,l)] -\u003e clean_up [(x,h);(x+l,0)] 0\n      | _         -\u003e\n        let first,rest = split l in\n        let sk1 = skyline first in\n        let sk2 = skyline rest in\n        let overlay = overlay sk1 sk2 0 0 in\n        let skyline = max_per_point overlay in\n        clean_up skyline 0\n\n(max_per_point could easily be inlined manually in overlay)\n\n\nThe implementation is purely functional and takes O(n logn) time.\n\n\nTo build and run:\n-----------------\n\nAt one command line run:\n\n    $ ocamlc -c skyline.ml visual.ml \n    $ ocaml skyline.cmo visual.cmo\n        OCaml version 4.01.0\n\n    # Visual.visualize (Visual.random_city());;\n    - : unit = ()\n    # \n\nThese commands will generate two files (lines.dat and skyline.dat)\ncontaining a randomly generated city and its corresponding skyline.\n\n\nIn another command line (in the same directory) plot the generated\ndata files using gnuplot (see http://www.gnuplot.info/):\n\n    $ gnuplot plotlines.gp\n\n\n(To generate more, generate a new random city from OCaml with\nVisual.visualize and plot it by invoking gnuplot again)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjmid%2Focaml-skyline","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjmid%2Focaml-skyline","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjmid%2Focaml-skyline/lists"}