Request a PoCDownload
Product

Platform

All features32 capabilities, from IDE to CICompliance KitsISO 26262, DO-178C, IEC 62304...AI GovernanceControl AI-generated C/C++ codeWhat’s new in 2026Latest version highlightsScreenshotsSee the product in action

Analyze & improve

Coding standardsMISRA, CERT, CWE, AUTOSARArchitecture & dependenciesGraphs, matrix, cyclesTechnical debtMeasured in hours and dollarsQuality gatesStop regressions in CISmart Code CityYour codebase in 3D

Integrations

IDE pluginsVisual Studio, VS Code, CLion...CI/CD pipelinesJenkins, Azure DevOps, GitHub, GitLabSonarQube pluginC/C++ results in SonarQubeExternal analyzersClang-Tidy, Cppcheck, coverageFeature on Demand
Solutions

By need

Functional safetyCompliance kits per standardCoding standardsMISRA, CERT, AUTOSAR, ISO...Legacy modernizationRefactor large C/C++ safelyCode auditExpert review of your codebaseM&A due diligenceAssess technical health fast

By role

DevelopersSoftware architectsTech leadsDevOps engineersEngineering managersProject managers

CTOsCIOs / IT leadersQA engineersSecurity leadersComplianceConsultantsRequest a guided PoC
Industries

Safety-critical

AutomotiveISO 26262, MISRA, AUTOSARAerospace & DefenseDO-178C programsMedical DevicesIEC 62304 softwareEnergy & UtilitiesIEC 61508 systemsEmbedded SystemsFirmware and devices

Enterprise

Financial ServicesTrading and paymentsGame DevelopmentEngines and large C++Software VendorsCommercial C/C++ productsGovernmentAgencies and contractorsAll industries & case studies
Resources

Learn

DocumentationGuides, rules and CI setupKnowledge baseFrequently asked questionsBlogC and C++ code quality articlesRelease notesEvery version since 2009

Customers

Case studiesSuccess storiesTestimonialsWhat users sayOur customersCompanies using CppDependGold Code QualityOpen source projects we rate

Programs & company

Feature on DemandMissing features built for freeFree for open sourceLicenses for OSS and studentsContact usSales and supportEULALicense agreement
DocsPricing
Documentation

User Guides

Dependency Structure Matrix (DSM): user guide

What the DSM is

The Dependency Structure Matrix shows the dependencies between code elements as a table instead of a diagram. The same elements are listed on the rows and on the columns, and each cell holds the dependency between its row element and its column element. A matrix stays readable with hundreds of elements, where a graph becomes unreadable, so it is the tool of choice for large applications, for finding dependency cycles, and for checking the layering of an architecture.

The Dependency Structure Matrix (DSM) page
The Dependency Structure Matrix (DSM) page

In the screenshot the elements are projects: the Inventory projects of the application, then the third-party elements (Windows SDK, STL, VCIncludes, Externals) on a bluish background. The number in a cell is the weight of the dependency (here: the number of members used).

Reading the matrix

Colors (legend, top left)

ColorMeaning
BlueRow uses column. The element of the row depends on the element of the column.
GreenColumn uses row. The element of the column depends on the element of the row.
RedCycle: both elements use each other. Cells in a cycle are also marked with a red triangle in their corner (with a small cycle icon when the cells are large enough) and a red border.
Hatched grayNot visible to each other: the two elements cannot depend on each other (for example a project that cannot see another one, or two fields), so nothing can be shown.
Diagonal lineThe row and the column are the same element, or one contains the other.
Dark empty cellNo dependency.

The number is the weight of the dependency (see Weight); an empty cell has no number. The shade of a blue or green cell shows the weight: the heavier the dependency, the brighter the cell, scaled separately for each direction between the lightest and the heaviest dependency of the matrix.

Rows, columns and headers

  • Row and column headers list the same elements. The + box in front of a header expands the element into its children (for example a project into its namespaces).
  • Third-party elements are shown on a different background than application elements, so they are easy to tell apart. A thin line marks the boundary between groups of rows and columns.
  • The two bars between the headers and the matrix can be dragged to resize the header areas. The matrix scrolls in both directions and the headers follow.

A quick example

Read a cell by looking at its row and its column. In the screenshot, the cell of row Inventory.Core, column Inventory shows 18 in the hover tooltip: Inventory uses 18 member(s) from Inventory.Core.

Toolbar reference

ControlWhat it does
View menu (first button)Chooses what the matrix shows: View Projects, View Application Projects Only, View Namespaces, View Application Namespaces Only. "Application only" removes third-party elements.
TriangularizeReorders the rows and columns so that the dependencies fall on one side of the diagonal, which reveals the layering. What remains on the wrong side, and the red cells, are layering violations and cycles.
Remove empty rows / columns (menu)Remove Empty Rows and Columns, Remove Empty Columns, Remove Empty Rows, Remove Rows with third party code elements, Remove Rows with application code elements. Use them to shrink a large matrix to what matters.
Swap rows and columns (menu)Swap Headers, Copy Vertical Headers to horizontal Header, Copy Horizontal Headers to Vertical Header. Disabled until the matrix can be modified this way (it is off at the start).
Undo / RedoStep back and forward through your changes to the matrix.
Export to Graph (menu)Export Elements To Graph, Export Horizontal Header To Graph, Export Vertical Header To Graph: opens the elements in the Call Graph.
Save the matrix as a PNG image (camera)Exports the matrix to an image.
Zoom out / Zoom inChanges the size of the cells. The number between the buttons is the current zoom level (19 in the screenshots).
WEIGHTWhat the number in each cell counts, and whether indirect dependencies are included (next section).
BINDDon't bind Columns and Rows (default) or Bind Columns and Rows: when bound, the columns follow the rows.
BulbShow details tooltip on hover: switches the hover tooltip on or off (on by default).

Weight: what the numbers count

The Weight menu
The Weight menu
Weight modeThe number in a cell is...
Direct & indirect depth of usehow far apart the two elements are in the use chain: 1 for a direct use, larger for an indirect use through other elements.
Direct: # namespacesthe number of namespaces of the used element that are used.
Direct: # typesthe number of types used.
Direct: # membersthe number of members (methods and fields) used. This is the mode of the screenshots.
Direct: # methodsthe number of methods used.
Direct: # fieldsthe number of fields used.

The two buttons next to the menu choose Direct dependencies (default) or Direct and Indirect dependencies. With indirect dependencies, an element that uses another one through intermediate elements also gets a cell. Start with members: the heavy cells are the strong couplings, and a heavy cell between two elements that should be independent is the one to investigate.

Hovering a cell

Hovering a cell: highlighted row and column, header labels and the details tooltip
Hovering a cell: highlighted row and column, header labels and the details tooltip
  • The row and the column of the cell are highlighted with a golden band and the cell gets a gold border, so you never lose track of which pair you are reading.
  • Labels with the names of the two elements appear on the headers.
  • A tooltip shows both elements with their metrics, LOC, Debt, Rating (A to E) and MI, and the sentence that explains the cell, for example uses 18 member(s) from. When the cell has a comparison state, the tooltip also shows the differences (the LOC, debt and MI variations).
  • The tooltip footer reminds the two actions: Double Click Show Dependencies Details and Right Click Advanced Actions.
  • An arrow beside the cell indicates the direction of the dependency (up for "row uses column", left for "column uses row", both for a cycle).

Switch the tooltip off with the bulb button if it hides the matrix.

Acting on a dependency

Double-click a cell to open the details of that dependency: the code elements that create the dependency between the row and the column elements.

Right-click a cell for the advanced actions:

Right-click menu on a cell
Right-click menu on a cell
ItemResult
Build a Graph made of Code Elements involved in this dependencyOpens a Call Graph with the elements behind the cell.
Open this dependency (default action, bold)Same as double-click.
Open this dependency (keep only involved dependencies)Opens the dependency and keeps only the dependencies involved in it.
Edit a code query that matches this dependencyCreates a CQLinq query selecting this dependency, so you can refine or save it.
Generate a code rule that warns if this dependency existsCreates a rule that fails when this dependency is found. Use it to forbid a dependency that violates your architecture, then enforce it in the quality gate and in CI.

Export a query result to the matrix

Any CQLinq query result can be shown in the matrix, to see how the elements it selects depend on each other. This answers questions such as "do the complex methods call each other?" or "which of these types use each other?".

  1. Open the Queries page and run a query that returns code elements. In the screenshot: the methods with a cyclomatic complexity above 10 (15 methods), grouped by project, namespace and type.
  2. Click the Export menu above the result and choose one of the matrix entries.
Export menu of a query result
Export menu of a query result
EntryResult
Export to matrixThe result elements are placed on both the rows and the columns: the matrix shows the dependencies among them.
Export to matrix rowsThe result elements become the rows of the matrix.
Export to matrix columnsThe result elements become the columns of the matrix.

The other entries of the same menu export the result to a graph or a treemap (see the Call Graph and Code Map guides) or to an HTML, Excel, XML or text file. The Group By buttons next to the menu choose how the result is grouped (project, namespace, type) and Scope limits the query to the solution or to a smaller scope.

Reading the exported matrix

The exported methods in the matrix
The exported methods in the matrix
  • The rows and columns are the methods of the result, organized under their type, namespace and project. The boxes with a minus sign collapse a group and the plus sign expands it again.
  • Cells follow the usual colors: blue row uses column, green column uses row, red cycle, hatched elements that cannot see each other.
  • In the screenshot a red frame surrounds a block of methods around the diagonal, with a red corner mark in its first cell: this marks a group of elements that depend on each other. Double-click a cell to see the dependency behind it.
  • Hovering a cell highlights its row and column (golden band) and shows the full name of the method on the header, here isValidEmail(conststd::string&).
  • All the toolbar actions work on the exported matrix: Triangularize, remove empty rows and columns, weight mode, zoom and export to graph or PNG.

Tip: use Remove Empty Rows and Columns after the export to keep only the elements that really depend on each other, then Triangularize to order them.

Recipes

  1. Find cycles. Choose View Application Projects Only (or namespaces), press Triangularize, and look for red cells: each pair of elements that use each other. Double-click one to see what creates the cycle.
  2. Check the layering. After Triangularize, cells on the wrong side of the diagonal are upward dependencies. Right-click one and generate a rule to forbid it.
  3. Who depends on STL? Read the STL row (or column): the cells list the application elements that use it, and the number says how many members.
  4. Shrink a big matrix. Use Remove Empty Rows and Columns, then remove third-party rows to concentrate on your own code.
  5. Go from matrix to picture. Export the elements to the Call Graph to see the same dependencies as arrows.
  6. Zoom to the details. Expand a project with the + box to see its namespaces, then again for types, and read weights by members.
Was this page helpful?Give feedbackRequest a feature