{"id":42253677,"url":"https://github.com/mbforbes/factorgraph-viz","last_synced_at":"2026-01-27T05:17:15.731Z","repository":{"id":57232368,"uuid":"95489207","full_name":"mbforbes/factorgraph-viz","owner":"mbforbes","description":"Factor graph visualization with d3.js","archived":false,"fork":false,"pushed_at":"2017-07-25T20:56:03.000Z","size":14910,"stargazers_count":25,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-10-19T17:42:27.331Z","etag":null,"topics":["d3","d3-force","d3js","factor","factor-graph","graph","visualization","viz"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mbforbes.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-06-26T21:01:40.000Z","updated_at":"2025-08-19T03:54:54.000Z","dependencies_parsed_at":"2022-08-31T14:10:46.122Z","dependency_job_id":null,"html_url":"https://github.com/mbforbes/factorgraph-viz","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mbforbes/factorgraph-viz","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mbforbes%2Ffactorgraph-viz","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mbforbes%2Ffactorgraph-viz/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mbforbes%2Ffactorgraph-viz/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mbforbes%2Ffactorgraph-viz/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mbforbes","download_url":"https://codeload.github.com/mbforbes/factorgraph-viz/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mbforbes%2Ffactorgraph-viz/sbom","scorecard":{"id":630937,"data":{"date":"2025-08-11","repo":{"name":"github.com/mbforbes/factorgraph-viz","commit":"c4a8a695a5040e65c92c3de94b915a228c02eb89"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Code-Review","score":0,"reason":"Found 0/28 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}}]},"last_synced_at":"2025-08-21T07:53:33.312Z","repository_id":57232368,"created_at":"2025-08-21T07:53:33.312Z","updated_at":"2025-08-21T07:53:33.312Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28803650,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-27T03:44:14.111Z","status":"ssl_error","status_checked_at":"2026-01-27T03:43:33.507Z","response_time":168,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["d3","d3-force","d3js","factor","factor-graph","graph","visualization","viz"],"created_at":"2026-01-27T05:17:15.022Z","updated_at":"2026-01-27T05:17:15.723Z","avatar_url":"https://github.com/mbforbes.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# factorgraph-viz\n\n[![Build Status](https://travis-ci.org/mbforbes/factorgraph-viz.svg?branch=master)](https://travis-ci.org/mbforbes/factorgraph-viz)\n[![license MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/mbforbes/factorgraph-viz/blob/master/LICENSE)\n\n![a demo of fg-visualizer in action](demo/threw.gif)\n\nThis is a small factor graph visualizer written in Typescript. It uses the\n[d3-force](https://github.com/d3/d3-force/) component of\n[D3.js](https://d3js.org/).\n\n## Installation\n\nYou can install `d3` (which is required at runtime) as well as the types and\nschema dependencies (which is required to update the code) all at once.\n\n```bash\nnpm install\n```\n\nA pre-compiled library is provided in `build/factorgraph-viz.js`. You can also\nproduce a fresh version:\n\n```bash\nnpm run-script compile\n```\n\n## Usage\n\nYou'll need to run a web server locally to serve up your factor graph data. The\nprovided script requires python and creates a server on port 8000.\n\n```bash\n./server.sh\n```\n\nVisiting `localhost:8000` will show `index.html`. The code loads the config file\n`data/config/default.json`, which in turn specifics where to look for factor\ngraphs:\n\n```js\n{\n    // This is where factorgraph files are located. It can be a local directory\n    // (like this) or the URL of a directory.\n    \"data_dir\": \"data/examples/\",\n\n    // This is a file (again, local or remote) that contains an array of\n    // strings. Each string should be the name of a .json file (without the\n    // .json extension) that lives in  `data_dir`. These are the factor graphs\n    // available to load.\n    \"data_filenames\": \"data/options/example-list.json\",\n\n    // This is a file to load on startup. It should be relative to `data_dir`\n    // and without the .json extension (just like the entries found in\n    // `data_filename`)\n    \"startup_filename\": \"07-complex-size-threw_d\",\n\n    // (config continues ...)\n}\n```\n\n**New:** The frontend provides autocomplete for strings (factor graph names)\nfound in the `data_filenames` list. The autocomplete suggestions are clickable,\nwhich will immediately load the corresponding factor graph.\n\n## Factor graph format\n\nIn order to produce a factor graph, you must save a JSON file that matches the\nrequired format.\n\n### Specification\n\nThe code requires a JSON object with two properties, `nodes` and `links`.\n\n- Every `node` needs a unique `id` property and a `type` property. The `type`\n  property can be either `\"rv\"` (random variable) or `\"fac\"` (factor). For nodes\n  with `\"type\": \"rv\"`, their `id` will be displayed in text next to them. For\n  nodes with `\"type\": \"fac\"`, an additional property `subtype` can be provided,\n  which will be displayed as text next to them. The property `\"focus\": true` can\n  be added to any node  and it will centered in the display.\n\n- Each `link` must have a `source` and `target` property. Both `source` and\n  `target` must match an `id` of one of the `node`s.\n\nA `weights` property can be added to any `node` or `link` and the code will\ncolorize that component accordingly. The value for `weights` should be an array\nof numbers, one for each value of the relevant random variable. The code will do\nan argmax and colorize based on the index of the highest weight. To customize\nthe colorization scheme, see below in [customization](#customization).\n\nSee below for [examples](#examples) of valid factor graph JSON files.\n\n### Schema validation\n\nTo aid in creating valid factor graph JSON files, a schema file is provided in\n`data/schema/factorgraph.json`. In addition, a simple JSON schema validation\ntool (which uses [`jsonschema`](https://www.npmjs.com/package/jsonschema)) is\nprovided in `build/validator.js`. You can use it to check whether your files\nconform to the spec required by this library.\n\nDon't forget to run `npm install` first.\n\n```bash\n# Check an individual file.\nnode build/validator.js data/schema/factorgraph.json data/examples/02-simple-onenode.json\n\n# Check all files in a directory.\nnode build/validator.js data/schema/factorgraph.json data/examples/\n```\n\n## Examples\n\n### Simple example\n\nHere is a simple example (`data/examples/03-simple-binaryfactor.json`). It\ncontains two random variables and one binary factor that connects them.\n\n```json\n{\n   \"nodes\": [\n      {\"id\": \"rv1\", \"type\": \"rv\", \"focus\": true},\n      {\"id\": \"rv2\", \"type\": \"rv\"},\n      {\"id\": \"fac1\", \"type\": \"fac\", \"subtype\": \"hello, world\"}\n   ],\n   \"links\": [\n      {\"source\": \"rv1\", \"target\": \"fac1\"},\n      {\"source\": \"fac1\", \"target\": \"rv2\"}\n   ]\n}\n```\n\nHere is how the above example is rendered:\n\n![A rendering of the simple binary factor factor graph\nexample](demo/simple-binaryfactor.png)\n\n### Colorized example\n\nThe following example (`data/examples/04-simple-binaryfactor-color.json`)\nprovides weights for the values of the random variables. It uses three values.\nThe colorization is based on the index of the greatest value. The default\ncolorization scheme uses red for the first value, blue for the second, and grey\nfor the third. This example also adds a unary factor to show that factors can\nalso have weights (and thus colors).\n\n```json\n{\n   \"nodes\": [\n      {\"id\": \"rv1\", \"type\": \"rv\", \"weights\": [0.7, 0.2, 0.1], \"focus\": true},\n      {\"id\": \"rv2\", \"type\": \"rv\", \"weights\": [0.1, 0.8, 0.1]},\n      {\"id\": \"fac1\", \"type\": \"fac\", \"subtype\": \"i'm a unary factor\",\n         \"weights\":[0.75, 0.1, 0.1]},\n      {\"id\": \"fac2\", \"type\": \"fac\", \"subtype\": \"i'm a binary factor\"}\n   ],\n   \"links\": [\n      {\"source\": \"rv1\", \"target\": \"fac1\", \"weights\":[0.75, 0.1, 0.1]},\n      {\"source\": \"rv1\", \"target\": \"fac2\", \"weights\":[0.65, 0.35, 0.1]},\n      {\"source\": \"fac2\", \"target\": \"rv2\", \"weights\":[0.05, 0.9, 0.05]}\n   ]\n}\n```\n\nHere is how it will be rendered:\n\n![A rendering of the simple binary factor colorized factor graph\nexample](demo/simple-binaryfactor-color.png)\n\n### Additional examples\n\nMore examples are provided in `data/examples/`. They are ordered from\nsimple to complex.\n\n## Customization\n\nThere are three places to configure `factorgraph-viz` without recompiling it:\n\n1.  in the config JSON file (found by default in `data/config/default.json`)\n2.  the CSS file (found by default in `css/default.css`)\n3.  the HTML file (`index.html`)\n\n\n### 1. `data/config/default.json`\n\nThis file is where all of the configuration is loaded. It specifies where factor\ngraph JSON files can be found, how large to render random variables and factors,\nthe strength and location of the positioning forces that alter the layout of the\nfactor graph, and the colorization scheme that is applied when the `weights`\nproperty is provided.\n\nMore detail is given about the configuration options at what they mean in the\nTypescript type that loads this object, which is located in\n[`src/config.ts`](https://github.com/mbforbes/factorgraph-viz/blob/master/src/config.ts).\n\n### 2. `css/default.css`\n\nDue to how SVG works, CSS cannot control the sizing of the random variables or\nfactors (which is why those are defined in the JSON config file). However, the\nvarious strokes for the factor graph shapes and the all of the font and styling\noptions for the text are specified in this CSS file.\n\n### 3. `index.html`\n\nThe HTML file is minimal, so there are probably only a few reasons why you might\nwant to configure it: (1) To change the location of `d3` (by default it is\nexpected to be found in `node_modules/d3/build/d3.js`), (2) to change the size\nof the SVG element (by default it is `800 x 600`), (3) To change the CSS file\nloaded (by default `css/default.css`), (4) To change the `factorgraph-viz`\nlibrary loaded (by default `build/factorgraph-viz.js`).\n\n## Contributing\n\nThere's plenty of low-hanging fruit to work on if you'd like to contribute to\nthis project. Here are a couple ideas:\n\n- [ ] Make an axis-specific [many body\n  force](https://github.com/d3/d3-force#forceManyBody). This could help separate\n  the nodes vertically so that the text doesn't overlap.\n\n- [ ] Compute stats of the factor graph on-the-fly and display them\n\n## See also\n\n- to learn more about factor graphs, check out the [Structured Belief\n  Propagation for NLP Tutorial](https://www.cs.cmu.edu/~mgormley/bp-tutorial/)\n  by Matthew R. Gormley and Jason Eisner.\n\n- [`py-factorgraph`](https://github.com/mbforbes/py-factorgraph) is a factor\n  graph and loopy belief propagation library, written in Python.\n\n- [verbphysics](https://github.com/uwnlp/verbphysics) is a project that uses\n  factor graphs. It makes use of both `py-factorgraph` and `factorgraph-viz`.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmbforbes%2Ffactorgraph-viz","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmbforbes%2Ffactorgraph-viz","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmbforbes%2Ffactorgraph-viz/lists"}