Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6641549
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:49:26+00:00 2026-05-25T23:49:26+00:00

I’m trying to construct a LayeredGraphPlot where some nodes connect to other nodes, like

  • 0

I’m trying to construct a LayeredGraphPlot where some nodes connect to other nodes, like a tree. I would like to have the freedom to choose the thickness, color, presence or absence of labeling of each edge.

I would also like to have the freedom to display some vertex names and display some vertices as just “dots”. I can’t seem to understand how EdgeRenderingFunction and VertexRenderingFunction enable me to do this.

I am new to mathematica. I’ve clicked on more information on Wolfram help page but it appears to have a vague description and not precise syntax, followed by some cute but unhelpful (to me) examples (As compared to matlab at mathworks where the help provides precise syntax.. at least in my mind).
I have looked up about 10 mathematics books (Smith and Blachman, mathematica demystified.. etc etc) but they all seem to cover the function superficially with one or two examples and not provide the most general syntax.

Can someone help with this and I would also appreciate tips on how to learn mathematica? I’m a smart guy and I should not have so much trouble learning how to use commands.

LayeredGraphPlot[{1->2,1->3,2->4,3->5,3->6}]

So for example, I’d like to:

  1. Suppress all the vertex names except vertices 4,5 and 6.
  2. Color as blue and thick the edges from 3->6, 2->4 and 1->3
  3. All the other edges to be red and thin
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T23:49:27+00:00Added an answer on May 25, 2026 at 11:49 pm

    VertexRenderingFunction and EdgeRenderingFunction allow you to take explicit control over the way that vertices and edges are drawn in the graph. Both functions are expected to return a symbolic graphics directive (or list of such directives) that is valid for the Graphics command.

    Let’s start with VertexRenderingFunction. We shall define a new function called drawVertex. A VertexRenderingFunction is called with two arguments: the position of the vertex (as an X/Y co-ordinate pair) and the name of the vertex.

    drawVertex[position_, vertex:(4 | 5 | 6)] :=
      Inset[Framed[vertex, Background -> LightMagenta], position]
    
    drawVertex[position_, _] :=
      {PointSize[Medium], Blue, Point[position]}
    

    Two definitions are provided for drawVertex. The first is only applicable to the vertices 4 or 5 or 6. It draws those vertices as framed labels. The second definition is applicable to all other vertices and draws simple blue points.

    Now for an EdgeRenderingFunction named drawEdge. The function will be passed three arguments: the endpoints of the edge, a list of the source and target vertices of the edge, and the label for the edge (if any). In our case, all edges will be drawn as arrows but the colour and thickness will vary depending upon the edge. The helper function edgeStyle is introduced to capture those differences:

    drawEdge[ends_, fromTo_, label_] :=
      Join[edgeStyle[fromTo], {Arrowheads[{{Automatic, 0.5}}], Arrow[ends]}]
    
    edgeStyle[{3, 6} | {2, 4} | {1, 3}] :=
      {Blue, Thick}
    
    edgeStyle[_] :=
      {Red, Thin}
    

    With these definitions in place, we can now use them in conjunction with LayeredGraphPlot to produce a customized diagram:

    LayeredGraphPlot[{1 -> 2, 1 -> 3, 2 -> 4, 3 -> 5, 3 -> 6},
      VertexRenderingFunction -> drawVertex, EdgeRenderingFunction -> drawEdge ]
    

    layered graph

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have some data like this: 1 2 3 4 5 9 2 6
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I would like to count the length of a string with PHP. The string
I am trying to loop through a bunch of documents I have to put
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a jquery bug and I've been looking for hours now, I can't

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.