# Graph components and pure layouts
Author the ten graph families with shared record accessors, or rebuild a view from immutable geometry.

## APIs demonstrated

- [DependencyGraph](/reference/components/graph-visualization/) from `@pibbl/core/viz`
- [ForceNetwork](/reference/components/graph-visualization/) from `@pibbl/core/viz`
- [TidyTree](/reference/components/graph-visualization/) from `@pibbl/core/viz`
- [AdjacencyMatrix](/reference/components/graph-visualization/) from `@pibbl/core/viz`
- [Sankey](/reference/components/graph-visualization/) from `@pibbl/core/viz`
- [BipartiteGraph](/reference/components/graph-visualization/) from `@pibbl/core/viz`
- [Treemap](/reference/components/graph-visualization/) from `@pibbl/core/viz`
- [RadialNeighborhood](/reference/components/graph-visualization/) from `@pibbl/core/viz`
- [Icicle](/reference/components/graph-visualization/) from `@pibbl/core/viz`
- [ChordDiagram](/reference/components/graph-visualization/) from `@pibbl/core/viz`
- [GraphView](/reference/components/graph-visualization/) from `@pibbl/core/viz`
- [layoutDependencies](/reference/components/graph-visualization/) from `@pibbl/core/viz`
- [layoutForceNetwork](/reference/components/graph-visualization/) from `@pibbl/core/viz`
- [layoutTree](/reference/components/graph-visualization/) from `@pibbl/core/viz`
- [layoutMatrix](/reference/components/graph-visualization/) from `@pibbl/core/viz`
- [layoutSankey](/reference/components/graph-visualization/) from `@pibbl/core/viz`
- [layoutBipartite](/reference/components/graph-visualization/) from `@pibbl/core/viz`
- [layoutTreemap](/reference/components/graph-visualization/) from `@pibbl/core/viz`
- [layoutNeighborhood](/reference/components/graph-visualization/) from `@pibbl/core/viz`
- [layoutIcicle](/reference/components/graph-visualization/) from `@pibbl/core/viz`
- [layoutChords](/reference/components/graph-visualization/) from `@pibbl/core/viz`
- [createForceSimulation](/reference/components/graph-visualization/) from `@pibbl/core/viz`

## Complete example

[Plain source](/minimal/viz/graph-visualizations.tsx). This example demonstrates a type-level or host-specific contract; it is checked with TypeScript rather than presented as an animated preview.

```tsx
import { createElement } from "@pibbl/core";
import {
  DependencyGraph,
  ForceNetwork,
  TidyTree,
  AdjacencyMatrix,
  Sankey,
  BipartiteGraph,
  Treemap,
  RadialNeighborhood,
  Icicle,
  ChordDiagram,
  GraphView,
  layoutDependencies,
  layoutForceNetwork,
  layoutTree,
  layoutMatrix,
  layoutSankey,
  layoutBipartite,
  layoutTreemap,
  layoutNeighborhood,
  layoutIcicle,
  layoutChords,
  createForceSimulation,
} from "@pibbl/core/viz";
const graph = {
  nodes: [
    { id: "supply", name: "Supply" },
    { id: "demand", name: "Demand" },
  ],
  edges: [{ id: "flow", from: "supply", to: "demand", amount: 100 }],
};
const access = {
  nodeKey: "id" as const,
  edgeKey: "id" as const,
  source: "from" as const,
  target: "to" as const,
  label: "name" as const,
};
const bounds = { x: 0, y: 0, width: 640, height: 400 };
const style = { width: 640, height: 400 };
interface Item {
  id: string;
  name: string;
  value: number;
  children?: Item[];
}
const root: Item = {
  id: "root",
  name: "Portfolio",
  value: 0,
  children: [{ id: "leaf", name: "Product", value: 100 }],
};
const hierarchy = {
  keyBy: "id" as const,
  childrenBy: "children" as const,
  label: "name" as const,
};
const matrix = {
  rows: graph.nodes,
  columns: graph.nodes,
  relations: graph.edges,
};
const matrixAccess = {
  rowKey: "id" as const,
  columnKey: "id" as const,
  source: "from" as const,
  target: "to" as const,
  value: "amount" as const,
  unit: "MWh/day",
};
const bipartite = {
  left: [graph.nodes[0]],
  right: [graph.nodes[1]],
  edges: graph.edges,
};
const bipartiteAccess = {
  leftKey: "id" as const,
  rightKey: "id" as const,
  edgeKey: "id" as const,
  source: "from" as const,
  target: "to" as const,
};
const chords = { categories: graph.nodes, transfers: graph.edges };
const chordAccess = {
  categoryKey: "id" as const,
  source: "from" as const,
  target: "to" as const,
  value: "amount" as const,
  unit: "MWh/day",
};
export const components = [
  <DependencyGraph graph={graph} {...access} style={style} />,
  <ForceNetwork graph={graph} {...access} style={style} />,
  <TidyTree root={root} {...hierarchy} style={style} />,
  <AdjacencyMatrix data={matrix} {...matrixAccess} style={style} />,
  <Sankey
    graph={graph}
    {...access}
    value="amount"
    unit="MWh/day"
    style={style}
  />,
  <BipartiteGraph graph={bipartite} {...bipartiteAccess} style={style} />,
  <Treemap root={root} {...hierarchy} value="value" unit="GB" style={style} />,
  <RadialNeighborhood
    graph={graph}
    {...access}
    centerKey="supply"
    hops={1}
    style={style}
  />,
  <Icicle root={root} {...hierarchy} value="value" unit="GB" style={style} />,
  <ChordDiagram data={chords} {...chordAccess} style={style} />,
];
export const geometry = [
  layoutDependencies(graph, { ...access, bounds }),
  layoutForceNetwork(graph, { ...access, bounds }),
  layoutTree(root, { ...hierarchy, bounds }),
  layoutMatrix(matrix, { ...matrixAccess, bounds }),
  layoutSankey(graph, { ...access, value: "amount", unit: "MWh/day", bounds }),
  layoutBipartite(bipartite, { ...bipartiteAccess, bounds }),
  layoutTreemap(root, { ...hierarchy, value: "value", unit: "GB", bounds }),
  layoutNeighborhood(graph, {
    ...access,
    centerKey: "supply",
    hops: 1,
    bounds,
  }),
  layoutIcicle(root, { ...hierarchy, value: "value", unit: "GB", bounds }),
  layoutChords(chords, { ...chordAccess, bounds }),
];
export const rebuilt = (
  <GraphView layout={layoutDependencies(graph, { ...access, bounds })} />
);
export const session = createForceSimulation(graph, { ...access, bounds });
session.step({ iterations: 4 });
export const withoutJsx = createElement(
  DependencyGraph<(typeof graph.nodes)[number], (typeof graph.edges)[number]>,
  { graph, ...access, style },
);

```

## Usage notes



## Documentation version

Documentation built with @pibbl/core 0.0.2, revision a1dcf8e. ALPHA — NOT FOR PRODUCTION USE.
