AI Glossary / AI and machine learning / Advanced

Moral graph

Definition

A moral graph is an undirected graph constructed from a directed acyclic graph by connecting every pair of nodes that share a child and then removing arrow directions. It is used in probabilistic graphical modeling and certain inference procedures.

What it means

The word moral is a historical graph-theory label, not an ethical assessment. The construction is sometimes described as “marrying the parents” because two parent nodes of the same child are joined even if the original graph has no edge between them.

In a Bayesian network, each variable's probability depends on its parents through a local conditional distribution. Moralization creates an undirected structure in which each variable and its parents form a connected group. This helps organize the factors used in probability calculations.

The transformed graph does not preserve every independence distinction visible in the original directed graph. It is a computational representation with a specific purpose, not a replacement causal explanation.

How it works

For each node, list its parents. Add an undirected edge between any pair of parents not already adjacent. Replace every original directed edge with an undirected edge, keeping the same nodes.

In junction-tree approaches to exact inference, moralization is followed by additional steps such as triangulation and construction of a suitable tree of cliques. The added edges can affect the size of groups processed together and therefore computational cost.

To use moralization for testing a particular directed separation statement, one works with the relevant ancestral subgraph before moralizing. Simply inspecting the moral graph of the entire network can lose distinctions needed for that query.

Three practical examples

  • A probabilistic-model developer converts a Bayesian network into an undirected structure as part of preparing exact inference.
  • A student checks which extra edges appear when several variables jointly influence one child node.
  • A systems team examines graph structure to understand why an apparently modest Bayesian network can still make inference expensive.

Think of it this way

Think of a project chart where several teams jointly contribute to one deliverable. A new coordination map directly links those contributing teams and then treats all links as undirected.

The analogy explains the added connections. It does not mean the teams directly caused one another's work, and the moral graph's new edges should likewise not be read as newly discovered causal relationships.

Worked example

Moralizing a small network

Suppose a directed graph contains A → C, B → C and C → D. A and B are both parents of C, so add the edge A - B. Remove the directions from the original edges.

The final moral graph has A - C, B - C, C - D and A - B. The three nodes A, B and C form a triangle. No B - D edge is required by this construction because B and D do not share a child in the original graph.

The original Bayesian-network factorization can be written as P(A)P(B)P(C given A,B)P(D given C). The factor for C involves A, B and C together, which helps explain the triangle in the undirected representation.

Although A and B were separate root variables in this example, their new edge does not announce that they are marginally dependent. It supports the transformed representation and must be interpreted in that context.

Illustrative case study

Fictional case: preparing a fault model

Elm Instruments, an invented equipment supplier, builds a small Bayesian network for a demonstration of fault diagnosis. Several possible causes feed into one observed alarm. When preparing an exact-inference implementation, an engineer moralizes the graph and sees the alarm's parent causes become mutually connected.

The team documents that these are computational edges. It keeps the original directed model for explaining the assumed dependency structure and reviews inference cost before adding many more parent variables.

The scenario illustrates model preparation rather than a verified diagnostic application. No claim is made about equipment safety, measured accuracy or a real company's results.

Common misconceptions and mistakes

Moralization has nothing to do with moral behavior or AI ethics. An added parent-to-parent edge is not evidence of a new causal mechanism. Moralization and triangulation are separate operations, even when both appear in the same inference pipeline.

Another mistake is assuming the whole moral graph exactly reproduces every directed independence relationship. Query-specific separation tests require the appropriate graph construction and conditioning rules.

Business use

Most business users will encounter moral graphs indirectly through probabilistic modeling software. Understanding the term helps them ask informed questions about why a model's structure affects inference cost and why a computational diagram differs from the original domain diagram.

For teams maintaining such systems, preserve both representations and label them clearly. Validate the original probability model and test the implementation on small examples with known results. Adding more dependencies can improve expressiveness but also increase computational burden. Graph conversion does not validate the underlying data, probability estimates or causal assumptions.

People also ask

Why connect parents?

Their child's conditional factor involves them jointly, which the undirected representation must accommodate.

Does moralization remove nodes?

No. The basic construction retains nodes while adding connections and removing arrow directions.

Is the result always a tree?

No. It can contain triangles and larger cycles.

Check your understanding

In A → C ← B, the moral graph adds A - B. Does that prove A causes B?

Answer: No. The edge is added by a graph-conversion rule because A and B share child C. It is not an empirical or causal discovery.

Related terms

  • Bayesian network
  • Directed acyclic graph
  • Conditional independence
  • factorisation
  • junction tree
  • triangulation

Learn next

Learn next how a collider differs from a chain in a directed graph. Then moralize several small examples and distinguish edges added by moralization from those added later by triangulation for an inference algorithm.

  • Directed graph

More in AI and machine learning

  • Momentum - Momentum is a training technique that lets an optimizer keep moving in its recent direction: each update blends the new gradient with a running average of...
  • Monolithic Machine Learning Pipeline - A monolithic machine learning pipeline is one built as a single welded unit: ingestion, cleaning, features, training and serving inside one program, so any...
  • Monte Carlo integration - Monte Carlo integration estimates an integral or average by random sampling: draw points at random, evaluate the quantity at each, and let the sample...
  • Moral outsourcing - Moral outsourcing is the shifting of responsibility for ethical judgment or harmful consequences onto an external person, organization or system.
  • Multi-class - Multi-class describes a classification setting where each item belongs to exactly one of three or more categories: a ticket routed to one of ten teams, a...
  • Multi-class classification - Multi-class classification is the task of assigning each item to exactly one category from three or more: routing a ticket to one of ten teams, tagging a...

Sources

Primary source: Lauritzen and Spiegelhalter, Local Computations with Probabilities on Graphical Structures, https://www.stats.ox.ac.uk/~steffen/papers/LS88.pdf . The original paper could not be retrieved. Robin Evans, Oxford Graphical Models notes, theorem 5.1 and its proof were consulted: https://www.stats.ox.ac.uk/~evans/APTS/gm.html. Independent editorial review is recorded, without publication approval. Graph example and case are original.

Previous: Monte Carlo tree search Next: Moral outsourcing

  • Home
  • Daily AI Updates
  • Blog
  • AIFBL Academy
  • AI Glossary
  • Products and Tools
  • Store
  • Free CFO AI Prompt Pack
  • About Shihan Sheriff
  • Privacy Policy
  • Terms of Use
  • Refund Policy
  • Cookie Policy
  • Earnings Disclaimer